Class UnsafeUtil

  • public class UnsafeUtil
    extends Object
    Utility methods allowing easy access to certain Unsafe functionality.
    • Constructor Detail

      • UnsafeUtil

        protected UnsafeUtil()
    • Method Detail

      • hasInvokeCleaner

        public static boolean hasInvokeCleaner()
        Returns true if sun.misc.Unsafe.invokeCleaner(java.nio.ByteBuffer) is available and has not caused an exception.
        See Also:
      • invokeCleaner

        public static boolean invokeCleaner​(ByteBuffer bb)
        Access to sun.misc.Unsafe.invokeCleaner(java.nio.ByteBuffer).

        If b is an direct NIO buffer, i.e DirectBuffer, calls it's sun.misc.Cleaner instance clean() method once.

        true if successful, otherwise false.
        See Also:
      • hasIllegalAccessLoggerAccess

        public static boolean hasIllegalAccessLoggerAccess()
        Returns true if access to jdk.internal.module.IllegalAcessLogger's logger field is available and has not caused an exception.
        See Also:
      • doWithoutIllegalAccessLogger

        public static <T> T doWithoutIllegalAccessLogger​(PrivilegedAction<T> action)
                                                  throws RuntimeException
        Issue the given user action while jdk.internal.module.IllegalAcessLogger's logger has been temporarily disabled.

        The caller shall place this call into their own SecurityUtil.doPrivileged(PrivilegedAction) block.

        In case the runtime is not PlatformPropsImpl.JAVA_9 or the logger is not accessible or disabling caused an exception, the user action is just executed w/o temporary logger modifications.

        action - the user action task
        RuntimeException - is thrown for a caught Throwable while executing the user action
        See Also: