On 05/07/2016 08:15, Wang Weijun wrote:

:
It's a runtime error.

@CallerSensitive
public static Unsafe getUnsafe() {
     Class<?> caller = Reflection.getCallerClass();
     if (!VM.isSystemDomainLoader(caller.getClassLoader()))
         throw new SecurityException("Unsafe"); <<<<<< The exception thrown
     return theUnsafe;
}

Just tried the one in jdk.unsupported, same error.

Okay, maybe this restriction in jdk.internal.misc.Unsafe needs to relaxed. For now then I assume you can read Unsafe.theUnsafe which is how user code typically gets it.

-Alan.

Reply via email to