RFR: 8357910: LoaderConstraintsTest.java fails when run with TEST_THREAD_FACTORY=Virtual [v2]

Patricio Chilano Mateo pchilanomate at openjdk.org
Mon Jun 2 14:24:13 UTC 2025


On Thu, 29 May 2025 07:11:36 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Patricio Chilano Mateo has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Add WhiteBox back + typo
>
> test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java line 53:
> 
>> 51:             ClassLoader cl = ClassUnloadCommon.newClassLoader();
>> 52:             Class<?> c = cl.loadClass("test.Empty");
>> 53:             // Causes class test.Emtpy to be linked, which triggers the
> 
> Suggestion:
> 
>             // Causes class test.Empty to be linked, which triggers the

Fixed.

> test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java line 66:
> 
>> 64:         Collections.addAll(argsList, args);
>> 65:         Collections.addAll(argsList, "-Xmn8m");
>> 66:         Collections.addAll(argsList, "-Xbootclasspath/a:.");
> 
> Without use of `WhiteBox`, you don't need this. And this is probably what caused the class to be loaded by the boot-loader instead of the custom loader as expected. But the use of WB is needed by `ClassUnloadCommon` and these instructions are present to ensure it works - as added by JDK-8289184.

Added back the use of `WhiteBox`. As to `test.Empty`, it was always loaded by the `app` classloader regardless of `-Xbootclasspath/a:.`, i.e that’s only needed for loading `WhiteBox`. The issue was the missing `test.class.path` property. Class `test.Empty` resides in directory `jtreg_test_hotspot_jtreg_runtime_logging_LoaderConstraintsTest_java/classes/0/runtime/logging/classes/test/` but the process’s current working directory is `jtreg_test_hotspot_jtreg_runtime_logging_LoaderConstraintsTest_java/scratch/0`, so setting the custom classloader classpath as `.` meant it wasn’t able to find it. So we ended up delegating to the parent classloader (`app`) which already had the correct directories in the classpath.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25496#discussion_r2121295912
PR Review Comment: https://git.openjdk.org/jdk/pull/25496#discussion_r2121299488


More information about the hotspot-runtime-dev mailing list