JDK-8289184 : runtime/ClassUnload/DictionaryDependsTest.java failed with "Test failed: should be unloaded"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x_10.15
  • CPU: x86_64
  • Submitted: 2022-06-25
  • Updated: 2024-10-30
  • Resolved: 2022-07-11
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 17 JDK 20
17.0.14Fixed 20 b06Fixed
Related Reports
Blocks :  
Relates :  
Description
The following test failed in the JDK20 CI:

runtime/ClassUnload/DictionaryDependsTest.java

Here's a snippet from the log file:

#section:main
----------messages:(5/486)----------
command: main -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -Xlog:class+unload -XX:+WhiteBoxAPI DictionaryDependsTest
reason: User specified action: run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -Xlog:class+unload -XX:+WhiteBoxAPI DictionaryDependsTest 
Mode: othervm [/othervm specified]
Additional options from @modules: --add-modules java.base,java.compiler --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
elapsed time (seconds): 1.082
----------configuration:(4/111)----------
Boot Layer
  add modules: java.base java.compiler     
  add exports: java.base/jdk.internal.misc ALL-UNNAMED

----------System.out:(6/219)----------
name is DictionaryDependsTest$c1r
name is p2.c2
c2 method2 called
c2 method2 called
Should not unload anything before here because class DictionaryDependsTest$c1r is still alive.
Should unload MyTest and p2.c2 just now
----------System.err:(12/830)----------
jdk.test.lib.classloader.ClassUnloadCommon$TestFailure: Test failed: should be unloaded
	at jdk.test.lib.classloader.ClassUnloadCommon.failIf(ClassUnloadCommon.java:50)
	at DictionaryDependsTest.main(DictionaryDependsTest.java:87)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:1589)

JavaTest Message: Test threw exception: jdk.test.lib.classloader.ClassUnloadCommon$TestFailure: Test failed: should be unloaded
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: jdk.test.lib.classloader.ClassUnloadCommon$TestFailure: Test failed: should be unloaded
----------rerun:(42/8447)*----------
Comments
Fix request [17u] I backport this to improve testing in 17. No risk, only a test change. Recognized clean after resolving, but added follow up JDK-8321299. Tests pass. SAP nightly testing passed.
14-10-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk17u-dev/pull/2937 Date: 2024-10-04 10:02:31 +0000
04-10-2024

Changeset: 0c1aa2bc Author: Coleen Phillimore <coleenp@openjdk.org> Date: 2022-07-11 15:34:17 +0000 URL: https://git.openjdk.org/jdk/commit/0c1aa2bc8a1c23d8da8673a4fac574813f373f57
11-07-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9435 Date: 2022-07-08 21:49:38 +0000
08-07-2022

Making ClassUnloadCommon.triggerUnloading() call WhiteBox.fullGC() is a more reliable way of making sure that the classes are unloaded. Unfortunately, there are two versions of WhiteBox and we're trying to migrate towards the jdk.test.whitebox.WhiteBox version. The fan-out from including this version in ClassUnloadCommon is huge. This is dependent on fixing JDK-8271707 first.
07-07-2022

This test looks like the GC hadn't run class unloading because of timing. From ClassUnloadCommon.java, all these tests use this function to trigger class unloading but this doesn't seem like it's guaranteed to actually do class unloading if the GC isn't ready to do so. Maybe it should have another System.gc() ? Maybe triggerUnloading() should use WhiteBox to make sure class unloading is done. public static void triggerUnloading() { allocateMemory(16 * 1024); // force young collection System.gc(); }
30-06-2022