diff --git a/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java b/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java index 4d59cfa89ab..7fd4726d9c6 100644 --- a/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java +++ b/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -70,10 +70,13 @@ public class ClassLoadUnloadTest { // Use the same command-line heap size setting as ../ClassUnload/UnloadTest.java static OutputAnalyzer exec(String... args) throws Exception { + String classPath = System.getProperty("test.class.path", "."); + + // Sub-process does not get all the properties automatically, so the test class path needs to be passed explicitly List argsList = new ArrayList<>(); Collections.addAll(argsList, args); Collections.addAll(argsList, "-Xmn8m", "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", "-XX:+ClassUnloading", ClassUnloadTestMain.class.getName()); + "-XX:+WhiteBoxAPI", "-XX:+ClassUnloading", "-Dtest.class.path=" + classPath, ClassUnloadTestMain.class.getName()); ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(argsList); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); @@ -86,7 +89,7 @@ public class ClassLoadUnloadTest { // -Xlog:class+unload=info output = exec("-Xlog:class+unload=info"); - checkFor(output, "[class,unload]", "unloading class"); + checkFor(output, "[class,unload]", "unloading class test.Empty"); // -Xlog:class+unload=off output = exec("-Xlog:class+unload=off");