Review Request JDK-8164512: Replace ClassLoader use of finalizer with phantom reference to unload native library

mandy chung mandy.chung at
Wed Sep 27 02:11:56 UTC 2017

On 9/26/17 7:06 PM, David Holmes wrote:
>> It is not tied with the Cleaner change. Instead, the FindClass bug 
>> blocks the finalizer to Cleaner change.
>> FindClass bug is uncovered when I implemented the change from 
>> finalizer to Cleaner (or phantom reference).   There is a test 
>> calling FindClass to look for a class defined by the class loader 
>> being unloaded, say L. L is not Gc'ed and so FindClass successfully 
>> finds the class (which resurrect the class loader which was marked 
>> finalizable).
>> Is that clearer?
> So the issue is only that this test breaks?? 

No.  The test reveals a bug in JNI_FindClass that uses a class loader 
being finalized as the context when NativeLibrary is the caller.
> And you want to change the FindClass spec to make it clear the test is 
> what needs to be changed?
No.   It is a bug in the hotspot implementation.   The JNI spec says 
that the context of JNI_OnUnload being called is unknown.  The hotspot 
implementation of FindClass uses the class loader associated with that 
native library as the context when invoked from JNI_OnUnload which is wrong.

I will file a separate JBS issue to separate this JNI bug.


More information about the hotspot-runtime-dev mailing list