6842 |
|
private static sun.misc.Unsafe getUnsafe() { |
6843 |
|
try { |
6844 |
|
return sun.misc.Unsafe.getUnsafe(); |
6845 |
< |
} catch (SecurityException se) { |
6846 |
< |
try { |
6847 |
< |
return java.security.AccessController.doPrivileged |
6848 |
< |
(new java.security |
6849 |
< |
.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
6850 |
< |
public sun.misc.Unsafe run() throws Exception { |
6851 |
< |
java.lang.reflect.Field f = sun.misc |
6852 |
< |
.Unsafe.class.getDeclaredField("theUnsafe"); |
6853 |
< |
f.setAccessible(true); |
6854 |
< |
return (sun.misc.Unsafe) f.get(null); |
6855 |
< |
}}); |
6856 |
< |
} catch (java.security.PrivilegedActionException e) { |
6857 |
< |
throw new RuntimeException("Could not initialize intrinsics", |
6858 |
< |
e.getCause()); |
6859 |
< |
} |
6845 |
> |
} catch (SecurityException tryReflectionInstead) {} |
6846 |
> |
try { |
6847 |
> |
return java.security.AccessController.doPrivileged |
6848 |
> |
(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
6849 |
> |
public sun.misc.Unsafe run() throws Exception { |
6850 |
> |
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class; |
6851 |
> |
for (java.lang.reflect.Field f : k.getDeclaredFields()) { |
6852 |
> |
f.setAccessible(true); |
6853 |
> |
Object x = f.get(null); |
6854 |
> |
if (k.isInstance(x)) |
6855 |
> |
return k.cast(x); |
6856 |
> |
} |
6857 |
> |
throw new NoSuchFieldError("the Unsafe"); |
6858 |
> |
}}); |
6859 |
> |
} catch (java.security.PrivilegedActionException e) { |
6860 |
> |
throw new RuntimeException("Could not initialize intrinsics", |
6861 |
> |
e.getCause()); |
6862 |
|
} |
6863 |
|
} |
6864 |
|
} |