On Fri, 2 Jun 2023 21:30:46 GMT, Chris Plummer <cjplum...@openjdk.org> wrote:

> Normally when a virtual thread wrapper is used to run a test, the main thread 
> is renamed to "old-m-a-i-n" and the new virtual thread that will act as the 
> main thread is named "main". Neither is being done by `ProcessTools.main()`. 
> This can cause problems for tests that expect the main thread that the test 
> is running in to be called "main". It is instead left unnamed. This is 
> causing the following 4 tests to fail:
> 
> com/sun/jdi/JdbMethodExitTest.java
> com/sun/jdi/JdbStepTest.java
> com/sun/jdi/JdbStopThreadTest.java
> com/sun/jdi/JdbStopThreadidTest.java
> 
> These tests also fail due to 
> [JDK-8309397](https://bugs.openjdk.org/browse/JDK-8309397), which will be 
> fixed after this CR, and also com/sun/jdi/JdbMethodExitTest.java fails due to 
> [JDK-8309396](https://bugs.openjdk.org/browse/JDK-8309396), which will also 
> subsequently be fixed.
> 
> Note this fix messed up one runtime test. It was expecting an exception 
> message to mention the "main" thread rather than "old-m-a-i-n". Loosening the 
> exception message matching pattern a bit solved the problem.
> 
> Testing was done by running all of tier1 and tier5.

test/lib/jdk/test/lib/process/ProcessTools.java line 899:

> 897:             // when main is executed in virtual thread
> 898:             MainThreadGroup tg = new MainThreadGroup();
> 899:             Thread vthread = createVirtualThread(() -> {

You can replace this with `Thread.ofVirtual().unstarted(() -> {` and remove the 
helper method. I think that helper method dates from the jtreg wrapper solution.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14292#discussion_r1215549528

Reply via email to