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

Patricio Chilano Mateo pchilanomate at openjdk.org
Wed May 28 14:54:24 UTC 2025


Please review this small test fix. When running LoaderConstraintsTest with `TEST_THREAD_FACTORY=Virtual` we load class `java.lang.Class` earlier than expected which causes the test to fail because of a missing loader constraint logging output. I added the full details of the issue in the JBS comments. 

The fix changes the constraint we look for to be on class `java.lang.String` between classloader `ClassUnloadCommonClassLoader` and the bootstrap classloader. This allows the test to be more robust and not depend on some hidden behavior. In fact, the only line that is currently needed for the test to pass for the platform thread case is the call to `ClassUnloadCommon.newClassLoader()`, which seems a bit obscure. Also as explained in JBS, the defining loader of `test.Empty` is currently the builtin system classloader, not `ClassUnloadCommonClassLoader` as the test would suggest.

Thanks,
Patricio

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

Commit messages:
 - v1

Changes: https://git.openjdk.org/jdk/pull/25496/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25496&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8357910
  Stats: 16 lines in 2 files changed: 4 ins; 6 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/25496.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25496/head:pull/25496

PR: https://git.openjdk.org/jdk/pull/25496


More information about the hotspot-runtime-dev mailing list