1142 |
|
private static sun.misc.Unsafe getUnsafe() { |
1143 |
|
try { |
1144 |
|
return sun.misc.Unsafe.getUnsafe(); |
1145 |
< |
} catch (SecurityException se) { |
1146 |
< |
try { |
1147 |
< |
return java.security.AccessController.doPrivileged |
1148 |
< |
(new java.security |
1149 |
< |
.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
1150 |
< |
public sun.misc.Unsafe run() throws Exception { |
1151 |
< |
java.lang.reflect.Field f = sun.misc |
1152 |
< |
.Unsafe.class.getDeclaredField("theUnsafe"); |
1153 |
< |
f.setAccessible(true); |
1154 |
< |
return (sun.misc.Unsafe) f.get(null); |
1155 |
< |
}}); |
1156 |
< |
} catch (java.security.PrivilegedActionException e) { |
1157 |
< |
throw new RuntimeException("Could not initialize intrinsics", |
1158 |
< |
e.getCause()); |
1159 |
< |
} |
1145 |
> |
} catch (SecurityException tryReflectionInstead) {} |
1146 |
> |
try { |
1147 |
> |
return java.security.AccessController.doPrivileged |
1148 |
> |
(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
1149 |
> |
public sun.misc.Unsafe run() throws Exception { |
1150 |
> |
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class; |
1151 |
> |
for (java.lang.reflect.Field f : k.getDeclaredFields()) { |
1152 |
> |
f.setAccessible(true); |
1153 |
> |
Object x = f.get(null); |
1154 |
> |
if (k.isInstance(x)) |
1155 |
> |
return k.cast(x); |
1156 |
> |
} |
1157 |
> |
throw new NoSuchFieldError("the Unsafe"); |
1158 |
> |
}}); |
1159 |
> |
} catch (java.security.PrivilegedActionException e) { |
1160 |
> |
throw new RuntimeException("Could not initialize intrinsics", |
1161 |
> |
e.getCause()); |
1162 |
|
} |
1163 |
|
} |
1164 |
|
} |