Procházet zdrojové kódy

Add sun.misc.Unsafe privileged retrieval to SecActions.

Also do it anonomously so as not to raise the alarms and upset the powers to be.
tags/rel_3_23_0_ga
nickl- před 6 roky
rodič
revize
02d023d7e5
1 změnil soubory, kde provedl 29 přidání a 0 odebrání
  1. 29
    0
      src/main/javassist/util/proxy/SecurityActions.java

+ 29
- 0
src/main/javassist/util/proxy/SecurityActions.java Zobrazit soubor

@@ -162,4 +162,33 @@ class SecurityActions {
}
}
}

static Object getSunMiscUnsafeAnonymously() throws ClassNotFoundException
{
try {
return AccessController.doPrivileged(
new PrivilegedExceptionAction<Object>() { public Object run() throws
ClassNotFoundException, NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException {
Class<?> unsafe = Class.forName("sun.misc.Unsafe");
Field theUnsafe = unsafe.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
Object usf = theUnsafe.get(null);
theUnsafe.setAccessible(false);
return usf;
}
});
}
catch (PrivilegedActionException e) {
if (e.getCause() instanceof ClassNotFoundException)
throw (ClassNotFoundException) e.getCause();
if (e.getCause() instanceof NoSuchFieldException)
throw new ClassNotFoundException("No such instance.", e.getCause());
if (e.getCause() instanceof IllegalAccessException
|| e.getCause() instanceof IllegalAccessException
|| e.getCause() instanceof SecurityException)
throw new ClassNotFoundException("Security denied access.", e.getCause());
throw new RuntimeException(e.getCause());
}
}
}

Načítá se…
Zrušit
Uložit