722 |
|
private static sun.misc.Unsafe getUnsafe() { |
723 |
|
try { |
724 |
|
return sun.misc.Unsafe.getUnsafe(); |
725 |
< |
} catch (SecurityException se) { |
726 |
< |
try { |
727 |
< |
return java.security.AccessController.doPrivileged |
728 |
< |
(new java.security |
729 |
< |
.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
730 |
< |
public sun.misc.Unsafe run() throws Exception { |
731 |
< |
java.lang.reflect.Field f = sun.misc |
732 |
< |
.Unsafe.class.getDeclaredField("theUnsafe"); |
733 |
< |
f.setAccessible(true); |
734 |
< |
return (sun.misc.Unsafe) f.get(null); |
735 |
< |
}}); |
736 |
< |
} catch (java.security.PrivilegedActionException e) { |
737 |
< |
throw new RuntimeException("Could not initialize intrinsics", |
738 |
< |
e.getCause()); |
739 |
< |
} |
725 |
> |
} catch (SecurityException tryReflectionInstead) {} |
726 |
> |
try { |
727 |
> |
return java.security.AccessController.doPrivileged |
728 |
> |
(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
729 |
> |
public sun.misc.Unsafe run() throws Exception { |
730 |
> |
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class; |
731 |
> |
for (java.lang.reflect.Field f : k.getDeclaredFields()) { |
732 |
> |
f.setAccessible(true); |
733 |
> |
Object x = f.get(null); |
734 |
> |
if (k.isInstance(x)) |
735 |
> |
return k.cast(x); |
736 |
> |
} |
737 |
> |
throw new NoSuchFieldError("the Unsafe"); |
738 |
> |
}}); |
739 |
> |
} catch (java.security.PrivilegedActionException e) { |
740 |
> |
throw new RuntimeException("Could not initialize intrinsics", |
741 |
> |
e.getCause()); |
742 |
|
} |
743 |
|
} |
744 |
|
} |