3410 |
|
private static sun.misc.Unsafe getUnsafe() { |
3411 |
|
try { |
3412 |
|
return sun.misc.Unsafe.getUnsafe(); |
3413 |
< |
} catch (SecurityException se) { |
3414 |
< |
try { |
3415 |
< |
return java.security.AccessController.doPrivileged |
3416 |
< |
(new java.security |
3417 |
< |
.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
3418 |
< |
public sun.misc.Unsafe run() throws Exception { |
3419 |
< |
java.lang.reflect.Field f = sun.misc |
3420 |
< |
.Unsafe.class.getDeclaredField("theUnsafe"); |
3421 |
< |
f.setAccessible(true); |
3422 |
< |
return (sun.misc.Unsafe) f.get(null); |
3423 |
< |
}}); |
3424 |
< |
} catch (java.security.PrivilegedActionException e) { |
3425 |
< |
throw new RuntimeException("Could not initialize intrinsics", |
3426 |
< |
e.getCause()); |
3427 |
< |
} |
3413 |
> |
} catch (SecurityException tryReflectionInstead) {} |
3414 |
> |
try { |
3415 |
> |
return java.security.AccessController.doPrivileged |
3416 |
> |
(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
3417 |
> |
public sun.misc.Unsafe run() throws Exception { |
3418 |
> |
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class; |
3419 |
> |
for (java.lang.reflect.Field f : k.getDeclaredFields()) { |
3420 |
> |
f.setAccessible(true); |
3421 |
> |
Object x = f.get(null); |
3422 |
> |
if (k.isInstance(x)) |
3423 |
> |
return k.cast(x); |
3424 |
> |
} |
3425 |
> |
throw new NoSuchFieldError("the Unsafe"); |
3426 |
> |
}}); |
3427 |
> |
} catch (java.security.PrivilegedActionException e) { |
3428 |
> |
throw new RuntimeException("Could not initialize intrinsics", |
3429 |
> |
e.getCause()); |
3430 |
|
} |
3431 |
|
} |
3430 |
– |
|
3432 |
|
} |