Remove unused code regarding sun.misc.Unsafe in util classes (#2285)
This commit is contained in:
parent
4498de480f
commit
38e0306f95
|
|
@ -194,44 +194,4 @@ final class EagleEyeCoreUtils {
|
|||
}
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
@SuppressWarnings("restriction")
|
||||
private static final sun.misc.Unsafe UNSAFE = doGetUnsafe();
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public static sun.misc.Unsafe getUnsafe() {
|
||||
return UNSAFE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package.
|
||||
* Replace with a simple call to Unsafe.getUnsafe when integrating into a
|
||||
* jdk.
|
||||
*
|
||||
* @return a sun.misc.Unsafe
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
private static sun.misc.Unsafe doGetUnsafe() {
|
||||
try {
|
||||
return sun.misc.Unsafe.getUnsafe();
|
||||
} catch (Throwable tryReflectionInstead) {
|
||||
}
|
||||
try {
|
||||
return java.security.AccessController
|
||||
.doPrivileged(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
|
||||
@Override
|
||||
public sun.misc.Unsafe run() throws Exception {
|
||||
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
|
||||
for (java.lang.reflect.Field f : k.getDeclaredFields()) {
|
||||
f.setAccessible(true);
|
||||
Object x = f.get(null);
|
||||
if (k.isInstance(x)) { return k.cast(x); }
|
||||
}
|
||||
throw new NoSuchFieldError("the Unsafe");
|
||||
}
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue