RFR: 8357914: TestEmptyBootstrapMethodsAttr.java fails when run with TEST_THREAD_FACTORY=Virtual [v2]

Patricio Chilano Mateo pchilanomate at openjdk.org
Thu Jun 5 04:43:47 UTC 2025


> Please review this small test fix. The test launches a child process with the only purpose of validating that the load of the main class (`emptynumbootstrapmethods1`/`emptynumbootstrapmethods2`) completes successfully and doesn’t throw `ClassFormatError`. The class doesn’t define a main method, so later during execution of `LauncherHelper.validateMainMethod` the child VM exits with the following error message which we check from the `OutputAnalyzer` output:
> 
> 
> Error: Main method not found in class emptynumbootstrapmethods1, please define the main method as:
>    public static void main(String[] args)
> or a JavaFX application class must extend javafx.application.Application
> 
> 
> The issue when the test is run with `TEST_THREAD_FACTORY=Virtual` is that loading of `emptynumbootstrapmethods1` is done in `jdk.test.lib.process.ProcessTools.main` (the actual entry point), which instead of calling `MethodFinder.findMainMethod(mainClass)` and aborting if result is null like `LauncherHelper` uses
> `Method mainMethod = c.getMethod("main", new Class<?>[] { String[].class });` which throws an exception instead and the test exits with the following error message:
> 
> 
> [Exception in thread "main" java.lang.NoSuchMethodException: emptynumbootstrapmethods1.main([Ljava.lang.String;)
> at java.base/java.lang.Class.getMethod(Class.java:2166)
> at jdk.test.lib.process.ProcessTools.main(ProcessTools.java:984)
> 
> 
> The proposed fix adjusts the output we check for based on whether the test was run on a platform thread or a virtual thread.
> 
> Thanks,
> Patricio

Patricio Chilano Mateo has updated the pull request incrementally with one additional commit since the last revision:

  Check vthread case on child's VM command

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/25509/files
  - new: https://git.openjdk.org/jdk/pull/25509/files/0c39d822..73c1ad2e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=25509&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=25509&range=00-01

  Stats: 4 lines in 1 file changed: 2 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/25509.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25509/head:pull/25509

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


More information about the hotspot-runtime-dev mailing list