org.apache.poi.poifs.nio

## Class CleanerUtil

- java.lang.Object
- - org.apache.poi.poifs.nio.CleanerUtil

-     public final class CleanerUtil
      extends java.lang.Object

  This is taken from Hadoop at https://issues.apache.org/jira/browse/HADOOP-12760 and https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/CleanerUtil.java Unfortunately this is not available in some general utility library yet, but hopefully will be at some point. sun.misc.Cleaner has moved in OpenJDK 9 and sun.misc.Unsafe#invokeCleaner(ByteBuffer) is the replacement. This class is a hack to use sun.misc.Cleaner in Java 8 and use the replacement in Java 9+. This implementation is inspired by LUCENE-6989.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `CleanerUtil.BufferCleaner` Pass in an implementation of this interface to cleanup ByteBuffers.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `UNMAP_NOT_SUPPORTED_REASON` if `UNMAP_SUPPORTED` is `false`, this contains the reason why unmapping is not supported.
    `static boolean` | `UNMAP_SUPPORTED` `true`, if this platform supports unmapping mmapped files.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static CleanerUtil.BufferCleaner` | `getCleaner()` Reference to a BufferCleaner that does unmapping.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### UNMAP_SUPPORTED

          public static final boolean UNMAP_SUPPORTED

      `true`, if this platform supports unmapping mmapped files.

    - #### UNMAP_NOT_SUPPORTED_REASON

          public static final java.lang.String UNMAP_NOT_SUPPORTED_REASON

      if `UNMAP_SUPPORTED` is `false`, this contains the reason why unmapping is not supported.

  - ### Method Detail

    - #### getCleaner

          public static CleanerUtil.BufferCleaner getCleaner()

      Reference to a BufferCleaner that does unmapping.
      Returns:
        `null` if not supported.

Copyright 2020 The Apache Software Foundation or its licensors, as applicable.