2700 |
|
private static sun.misc.Unsafe getUnsafe() { |
2701 |
|
try { |
2702 |
|
return sun.misc.Unsafe.getUnsafe(); |
2703 |
< |
} catch (SecurityException se) { |
2704 |
< |
try { |
2705 |
< |
return java.security.AccessController.doPrivileged |
2706 |
< |
(new java.security |
2707 |
< |
.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
2708 |
< |
public sun.misc.Unsafe run() throws Exception { |
2709 |
< |
java.lang.reflect.Field f = sun.misc |
2710 |
< |
.Unsafe.class.getDeclaredField("theUnsafe"); |
2711 |
< |
f.setAccessible(true); |
2712 |
< |
return (sun.misc.Unsafe) f.get(null); |
2713 |
< |
}}); |
2714 |
< |
} catch (java.security.PrivilegedActionException e) { |
2715 |
< |
throw new RuntimeException("Could not initialize intrinsics", |
2716 |
< |
e.getCause()); |
2717 |
< |
} |
2703 |
> |
} catch (SecurityException tryReflectionInstead) {} |
2704 |
> |
try { |
2705 |
> |
return java.security.AccessController.doPrivileged |
2706 |
> |
(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
2707 |
> |
public sun.misc.Unsafe run() throws Exception { |
2708 |
> |
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class; |
2709 |
> |
for (java.lang.reflect.Field f : k.getDeclaredFields()) { |
2710 |
> |
f.setAccessible(true); |
2711 |
> |
Object x = f.get(null); |
2712 |
> |
if (k.isInstance(x)) |
2713 |
> |
return k.cast(x); |
2714 |
> |
} |
2715 |
> |
throw new NoSuchFieldError("the Unsafe"); |
2716 |
> |
}}); |
2717 |
> |
} catch (java.security.PrivilegedActionException e) { |
2718 |
> |
throw new RuntimeException("Could not initialize intrinsics", |
2719 |
> |
e.getCause()); |
2720 |
|
} |
2721 |
|
} |
2720 |
– |
|
2722 |
|
} |