Skip to content

Commit

Permalink
8289184: runtime/ClassUnload/DictionaryDependsTest.java failed with "…
Browse files Browse the repository at this point in the history
…Test failed: should be unloaded"

Reviewed-by: lmesnik, hseigel
  • Loading branch information
coleenp committed Jul 11, 2022
1 parent c33fa55 commit 0c1aa2b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java
@@ -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
Expand Down Expand Up @@ -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
*/

Expand Down Expand Up @@ -77,7 +79,9 @@ static ProcessBuilder exec(String... args) throws Exception {
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);
Expand Down
8 changes: 6 additions & 2 deletions test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java
@@ -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
Expand Down Expand Up @@ -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
*/

Expand Down Expand Up @@ -60,7 +62,9 @@ static ProcessBuilder exec(String... args) throws Exception {
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);
}
Expand Down
7 changes: 4 additions & 3 deletions test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java
Expand Up @@ -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;
Expand Down Expand Up @@ -62,8 +63,8 @@ private static void allocateMemory(int kilobytes) {
}

public static void triggerUnloading() {
allocateMemory(16 * 1024); // force young collection
System.gc();
WhiteBox wb = WhiteBox.getWhiteBox();
wb.fullGC(); // will do class unloading
}

/**
Expand Down

1 comment on commit 0c1aa2b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.