Remove unused code regarding sun.misc.Unsafe in util classes (#2285)

This commit is contained in:
xiaojun207 2021-07-09 23:30:54 +08:00 committed by GitHub
parent 4498de480f
commit 38e0306f95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 40 deletions

View File

@ -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;
}
}
}