Skip to content

8357910: LoaderConstraintsTest.java fails when run with TEST_THREAD_FACTORY=Virtual #2096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/hotspot/jtreg/ProblemList-Virtual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ gc/arguments/TestNewSizeThreadIncrease.java 0000000 generic-all
gc/g1/TestSkipRebuildRemsetPhase.java 0000000 generic-all
runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java JDK-8346442 generic-all
runtime/ErrorHandling/MachCodeFramesInErrorFile.java 0000000 generic-all
runtime/logging/LoaderConstraintsTest.java JDK-8346442 generic-all
runtime/Thread/AsyncExceptionOnMonitorEnter.java 0000000 generic-all
runtime/Thread/StopAtExit.java 0000000 generic-all
runtime/handshake/HandshakeWalkStackTest.java 0000000 generic-all
17 changes: 10 additions & 7 deletions test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, 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 @@ -38,6 +38,7 @@
import jdk.test.lib.process.OutputAnalyzer;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -49,22 +50,25 @@ public class LoaderConstraintsTest {
private static ProcessBuilder pb;
private static class ClassUnloadTestMain {
public static void main(String... args) throws Exception {
String className = "test.Empty";
ClassLoader cl = ClassUnloadCommon.newClassLoader();
Class<?> c = cl.loadClass(className);
cl = null; c = null;
ClassUnloadCommon.triggerUnloading();
Class<?> c = cl.loadClass("test.Empty");
// Causes class test.Empty to be linked, which triggers the
// constraint on class String due to override of toString().
Constructor<?> constructor = c.getDeclaredConstructor();
}
}

// Use the same command-line heap size setting as ../ClassUnload/UnloadTest.java
static ProcessBuilder exec(String... args) throws Exception {
String classPath = System.getProperty("test.class.path", ".");

List<String> argsList = new ArrayList<>();
Collections.addAll(argsList, args);
Collections.addAll(argsList, "-Xmn8m");
Collections.addAll(argsList, "-Xbootclasspath/a:.");
Collections.addAll(argsList, "-XX:+UnlockDiagnosticVMOptions");
Collections.addAll(argsList, "-XX:+WhiteBoxAPI");
Collections.addAll(argsList, "-Dtest.class.path=" + classPath);
Collections.addAll(argsList, ClassUnloadTestMain.class.getName());
return ProcessTools.createLimitedTestJavaProcessBuilder(argsList);
}
Expand All @@ -75,13 +79,12 @@ public static void main(String... args) throws Exception {
pb = exec("-Xlog:class+loader+constraints=info");
out = new OutputAnalyzer(pb.start());
out.shouldHaveExitValue(0);
out.shouldContain("[class,loader,constraints] adding new constraint for name: java/lang/Class, loader[0]: 'app', loader[1]: 'bootstrap'");
out.stdoutShouldMatch("\\[class,loader,constraints\\] adding new constraint for name: java/lang/String, loader\\[0\\]: 'ClassUnloadCommonClassLoader' @[\\da-f]+, loader\\[1\\]: 'bootstrap'");

// -Xlog:class+loader+constraints=off
pb = exec("-Xlog:class+loader+constraints=off");
out = new OutputAnalyzer(pb.start());
out.shouldHaveExitValue(0);
out.shouldNotContain("[class,loader,constraints]");

}
}