JDK-8148117 : Move sun.misc.Cleaner to jdk.internal.ref
  • Type: Sub-task
  • Component: core-libs
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-01-23
  • Updated: 2017-02-02
  • Resolved: 2016-02-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b105Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Description
sun.misc.Cleaner was previously listed as a critical internal API in JEP 260, JDK-8132928, 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, JDK-8138696, 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.

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. 
Comments
Issues tracking some third party library updates: Apache Lucene: https://issues.apache.org/jira/browse/LUCENE-6989 Netty: https://github.com/netty/netty/issues/4756 Hadoop: https://issues.apache.org/jira/browse/HADOOP-12760
05-02-2016