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 longgetLong(long address)static longgetLong(Object o, long offset)static ObjectgetObject(Object o, long offset)static ObjectgetObjectVolatile(Object o, long offset)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).static voidputLong(long address, long x)static voidputLong(Object o, long offset, long x)static voidputObject(Object o, long offset, Object x)static voidputObjectVolatile(Object o, long offset, Object x)static longstaticFieldOffset(Field f)
-
-
-
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.eDirectBuffer, calls it'ssun.misc.Cleanerinstanceclean()method once.- Returns:
trueif successful, otherwisefalse.- See Also:
hasInvokeCleaner()
-
staticFieldOffset
public static long staticFieldOffset(Field f)
-
getLong
public static long getLong(Object o, long offset)
-
putLong
public static void putLong(Object o, long offset, long x)
-
getLong
public static long getLong(long address)
-
putLong
public static void putLong(long address, long x)
-
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()
-
-