sun.misc.Cleaner was previously listed as a critical internal API in JEP
260 [1], but on further investigation it has been moved to an open issue,
for the following reasons:
  1) its primary use in the JDK is within NIO direct buffers to release
     native memory. The base module cannot have a dependency on the
     jdk.unsupported module so will need to be updated to use an
     alternative cleaner,
  2) the usage of Cleaner outside the JDK, as determined by corpus
     analysis, has largely been observed to hack into private fields of
     the internal NIO direct buffer classes to explicitly release native
     memory.

As stated in 1), the type of the cleaner used by NIO direct buffers will
have to change. Given this, and the fact that JDK 9 has a new general
purposed cleaner API, java.lang.ref.Cleaner [2] the value of keep
sun.misc.Cleaner is questionable.

This issue proposes to simply move Cleaner into an internal non-exported
package in the base module so that it can be used by the NIO direct
buffers classes, and small number of other places.

Webrev:
  http://cr.openjdk.java.net/~chegar/8148117/


If, at some point in the future, it is determined that sun.misc.Cleaner
is in fact a critical internal API ( with static usage ), then it can be
reinstated as a subtype of jdk.internal.ref.Cleaner, providing the same
public API.

Note: some popular open source libraries that hack into the internal
private cleaner field of direct buffers will have to have their code
updated, if they wish to continue to do this.

-Chris.

[1] https://bugs.openjdk.java.net/browse/JDK-8132928
[1] https://bugs.openjdk.java.net/browse/JDK-8138696

Reply via email to