8289184: runtime/ClassUnload/DictionaryDependsTest.java failed with "Test failed: should be unloaded"

Reviewed-by: lmesnik, hseigel
This commit is contained in:
Coleen Phillimore 2022-07-11 15:34:17 +00:00
parent c33fa55cf8
commit 0c1aa2bc8a
5 changed files with 24 additions and 11 deletions
test
hotspot/jtreg/runtime
lib/jdk/test/lib/classloader

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,7 +32,9 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.compiler
* @run main TestUnloadClassError
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestUnloadClassError
*/
import jdk.test.lib.compiler.InMemoryJavaCompiler;

@ -34,8 +34,10 @@
* PackagedNestHost.java
* PackagedNestHost2.java
* @compile PackagedNestHost2Member.jcod
*
* @run main/othervm -Xlog:class+unload=trace TestNestHostErrorWithClassUnload
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xlog:class+unload=trace TestNestHostErrorWithClassUnload
*/
// Test setup:

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -30,6 +30,8 @@
* @library /test/lib
* @library classes
* @build test.Empty
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run driver ClassLoadUnloadTest
*/
@ -77,7 +79,9 @@ public class ClassLoadUnloadTest {
List<String> argsList = new ArrayList<>();
Collections.addAll(argsList, args);
Collections.addAll(argsList, "-Xmn8m");
Collections.addAll(argsList, "-Dtest.class.path=" + System.getProperty("test.class.path", "."));
Collections.addAll(argsList, "-Xbootclasspath/a:.");
Collections.addAll(argsList, "-XX:+UnlockDiagnosticVMOptions");
Collections.addAll(argsList, "-XX:+WhiteBoxAPI");
Collections.addAll(argsList, "-XX:+ClassUnloading");
Collections.addAll(argsList, ClassUnloadTestMain.class.getName());
return ProcessTools.createJavaProcessBuilder(argsList);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,8 @@
* @modules java.base/jdk.internal.misc
* @library /test/lib classes
* @build test.Empty
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run driver LoaderConstraintsTest
*/
@ -60,7 +62,9 @@ public class LoaderConstraintsTest {
List<String> argsList = new ArrayList<>();
Collections.addAll(argsList, args);
Collections.addAll(argsList, "-Xmn8m");
Collections.addAll(argsList, "-Dtest.classes=" + System.getProperty("test.classes","."));
Collections.addAll(argsList, "-Xbootclasspath/a:.");
Collections.addAll(argsList, "-XX:+UnlockDiagnosticVMOptions");
Collections.addAll(argsList, "-XX:+WhiteBoxAPI");
Collections.addAll(argsList, ClassUnloadTestMain.class.getName());
return ProcessTools.createJavaProcessBuilder(argsList);
}

@ -23,12 +23,13 @@
/*
* To use ClassUnloadCommon from a sub-process, see hotspot/test/runtime/logging/ClassLoadUnloadTest.java
* To use ClassUnloadCommon from a sub-process, see test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java
* for an example.
*/
package jdk.test.lib.classloader;
import jdk.test.whitebox.WhiteBox;
import java.io.File;
import java.net.MalformedURLException;
@ -62,8 +63,8 @@ public class ClassUnloadCommon {
}
public static void triggerUnloading() {
allocateMemory(16 * 1024); // force young collection
System.gc();
WhiteBox wb = WhiteBox.getWhiteBox();
wb.fullGC(); // will do class unloading
}
/**