use of sun.misc.Unsafe in project es6draft by anba.
the class UnsafeHolder method initializeUnsafe.
private static Unsafe initializeUnsafe() {
try {
return Unsafe.getUnsafe();
} catch (SecurityException e) {
try {
return AccessController.doPrivileged((PrivilegedExceptionAction<Unsafe>) () -> {
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
return (Unsafe) f.get(null);
});
} catch (PrivilegedActionException e2) {
throw new ExceptionInInitializerError(e2.getException());
}
}
}
use of sun.misc.Unsafe in project quasar by puniverse.
the class UtilUnsafe method getUnsafe1.
public static Unsafe getUnsafe1() {
// Not on bootclasspath
if (UtilUnsafe.class.getClassLoader() == null)
return Unsafe.getUnsafe();
try {
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
return (Unsafe) f.get(UtilUnsafe.class);
} catch (Exception e) {
throw new RuntimeException("Could not obtain access to sun.misc.Unsafe", e);
}
}
use of sun.misc.Unsafe in project quasar by puniverse.
the class UtilUnsafe method getUnsafe.
public static Unsafe getUnsafe() {
try {
return Unsafe.getUnsafe();
} catch (SecurityException se) {
try {
return java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<Unsafe>() {
@Override
public Unsafe run() throws Exception {
final Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
if (true) {
final Field f = k.getDeclaredField("theUnsafe");
f.setAccessible(true);
final Object x = f.get(null);
return k.cast(x);
} else {
for (Field f : k.getDeclaredFields()) {
f.setAccessible(true);
final Object x = f.get(null);
if (k.isInstance(x))
return k.cast(x);
}
throw new NoSuchFieldError("the Unsafe");
}
}
});
} catch (java.security.PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
}
use of sun.misc.Unsafe in project hadoop by apache.
the class NativeIO method getOperatingSystemPageSize.
/**
* @return the operating system's page size.
*/
static long getOperatingSystemPageSize() {
try {
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
Unsafe unsafe = (Unsafe) f.get(null);
return unsafe.pageSize();
} catch (Throwable e) {
LOG.warn("Unable to get operating system page size. Guessing 4096.", e);
return 4096;
}
}
use of sun.misc.Unsafe in project wildfly by wildfly.
the class FastConcurrentDirectDeque method getUnsafe0.
private static Unsafe getUnsafe0() {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
return (Unsafe) theUnsafe.get(null);
} catch (Throwable t) {
throw new RuntimeException("JDK did not allow accessing unsafe", t);
}
}
Aggregations