private static BufferCleaner newBufferCleaner(
      final Class<?> unmappableBufferClass, final MethodHandle unmapper) {
    assert Objects.equals(
        methodType(void.class, ByteBuffer.class), unmapper.type());
    return buffer -> {
      if (!buffer.isDirect()) {
        throw new IllegalArgumentException(
            "unmapping only works with direct buffers");
      }
      if (!unmappableBufferClass.isInstance(buffer)) {
        throw new IllegalArgumentException("buffer is not an instance of " +
            unmappableBufferClass.getName());
      }
      final Throwable error = AccessController.doPrivileged(
          (PrivilegedAction<Throwable>) () -> {
            try {
              unmapper.invokeExact(buffer);
              return null;
            } catch (Throwable t) {
              return t;
            }
          });
      if (error != null) {
        throw new IOException("Unable to unmap the mapped buffer", error);
      }
    };
  }
Reference to a BufferCleaner that does unmapping.
@return {@code null} if not supported.
common/src/java/org/apache/hive/common/util/CleanerUtil.java