JDK-8164512 : Replace ClassLoader use of finalizer with phantom reference to unload native library
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:class_loading
  • Affected Version: 10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-08-19
  • Updated: 2018-03-23
  • Resolved: 2017-11-07
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 10
10 b31Fixed
Related Reports
Blocks :  
CSR :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
This issue will track the work to convert ClassLoader finalizer to use phantom reference to unload native library.

An earlier prototype uncovers an issue related to JNI_FindClass that is called during JNI_OnUnload that resurrects the caller class which has been GC'ed.

I think JNI FindClass should not be called during JNI_OnUnload [1].   This would require further investigation, for example, whether it's possible to prohibit JNI_FindClass is called during JNI_OnUnload (to avoid resurrecting the caller's class).  Also might be useful to gather some data to determine how high the compatibility risk is for JNI_FindClass not to work in JNI_OnUnload. 

1] https://bugs.openjdk.java.net/browse/JDK-4240589?focusedCommentId=13474512&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13474512