JDK-8168682 : jdk/test/java/lang/ClassLoader/forNameLeak/ClassForNameLeak.java fails with -Xcomp: ClassLoader was never enqueued!
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:class_loading
  • Affected Version: 8,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-10-25
  • Updated: 2020-11-30
  • Resolved: 2018-02-12
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 11 JDK 8 Other
11 b01Fixed 8u281Fixed openjdk8u282Fixed
Related Reports
Duplicate :  
Relates :  
Description
jdk/test/java/lang/ClassLoader/forNameLeak/ClassForNameLeak.java is a regression test created for     
JDK-8151486: Class.forName causes memory leak

The test uses PhantomReferences to verify that instances of ClassLoader are garbage collected. The test works well, but fails if the -Xcomp VM flag is given:

----------System.out:(11/888)----------
returning phantom ref: java.lang.ref.PhantomReference@2f43ab0d to LeakedClassLoader
returning phantom ref: java.lang.ref.PhantomReference@2ff14224 to LeakedClassLoader
returning phantom ref: java.lang.ref.PhantomReference@6bebaa4a to LeakedClassLoader
returning phantom ref: java.lang.ref.PhantomReference@4006b63a to LeakedClassLoader
returning phantom ref: java.lang.ref.PhantomReference@58140e41 to LeakedClassLoader
returning phantom ref: java.lang.ref.PhantomReference@745902d6 to LeakedClassLoader
returning phantom ref: java.lang.ref.PhantomReference@3597967c to LeakedClassLoader
returning phantom ref: java.lang.ref.PhantomReference@ee64986 to LeakedClassLoader
returning phantom ref: java.lang.ref.PhantomReference@6ae29f7d to LeakedClassLoader
returning phantom ref: java.lang.ref.PhantomReference@301bfb23 to LeakedClassLoader
Enqueued java.lang.ref.PhantomReference@3597967c
----------System.err:(13/897)----------
java.lang.RuntimeException: ClassLoader was never enqueued!
	at ClassForNameLeak.main(ClassForNameLeak.java:114)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-internal/Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-internal/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-internal/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@9-internal/Method.java:537)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110)
	at java.lang.Thread.run(java.base@9-internal/Thread.java:844)

The problem is well reproducible will any GC.


Comments
Fix Request (8u) I would like to backport this patch to OpenJDK 8u for parity with Oracle 8u281. The original patch does not apply cleanly. 8u patch has been reviewed by Paul (phh)
28-10-2020

8u code review: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-October/012863.html
27-10-2020

Maybe this test needs to be rewritten or removed. See my comments in JDK-8146090.
14-11-2017

The problem is recognized as bug in compiler (jit). A separate bug has been filed against that problem, so I'm closing this one as a duplicate.
01-11-2016

The problem could be in: - the test (most likely) - GC - jit compiler I will investigate and provide the analysis.
25-10-2016