Package com.jogamp.common.util
Class UnsafeUtil
- java.lang.Object
-
- com.jogamp.common.util.UnsafeUtil
-
public class UnsafeUtil extends Object
Utility methods allowing easy access to certainUnsafefunctionality.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedUnsafeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TdoWithoutIllegalAccessLogger(PrivilegedAction<T> action)Issue the given useractionwhilejdk.internal.module.IllegalAcessLogger'sloggerhas been temporarily disabled.static booleanhasIllegalAccessLoggerAccess()Returnstrueif access tojdk.internal.module.IllegalAcessLogger'sloggerfield is available and has not caused an exception.static booleanhasInvokeCleaner()Returnstrueifsun.misc.Unsafe.invokeCleaner(java.nio.ByteBuffer)is available and has not caused an exception.static booleaninvokeCleaner(ByteBuffer bb)Access tosun.misc.Unsafe.invokeCleaner(java.nio.ByteBuffer).
-
-
-
Method Detail
-
hasInvokeCleaner
public static boolean hasInvokeCleaner()
Returnstrueifsun.misc.Unsafe.invokeCleaner(java.nio.ByteBuffer)is available and has not caused an exception.- See Also:
invokeCleaner(ByteBuffer)
-
invokeCleaner
public static boolean invokeCleaner(ByteBuffer bb)
Access tosun.misc.Unsafe.invokeCleaner(java.nio.ByteBuffer).If
bis an direct NIO buffer, i.esun.nio.ch.DirectBuffer, calls it'ssun.misc.Cleanerinstanceclean()method once.- Returns:
trueif successful, otherwisefalse.- See Also:
hasInvokeCleaner()
-
hasIllegalAccessLoggerAccess
public static boolean hasIllegalAccessLoggerAccess()
Returnstrueif access tojdk.internal.module.IllegalAcessLogger'sloggerfield is available and has not caused an exception.
-
doWithoutIllegalAccessLogger
public static <T> T doWithoutIllegalAccessLogger(PrivilegedAction<T> action) throws RuntimeException
Issue the given useractionwhilejdk.internal.module.IllegalAcessLogger'sloggerhas been temporarily disabled.The caller shall place this call into their own
SecurityUtil.doPrivileged(PrivilegedAction)block.In case the runtime is not
PlatformPropsImpl.JAVA_9or the logger is not accessible or disabling caused an exception, the useractionis just executed w/o temporary logger modifications.- Parameters:
action- the user action task- Throws:
RuntimeException- is thrown for a caughtThrowablewhile executing the useraction- See Also:
hasIllegalAccessLoggerAccess()
-
-