On Tue, 11 Feb 2025 02:45:11 GMT, SendaoYan <s...@openjdk.org> wrote:

> H all,
> 
> This PR add `/native` keyword in the test header for virtual thread tests. 
> The `/native` keyword will make run the related tests by jtreg standalone 
> more friendly.
> 
> I runed all the tests without -nativepath argument and find the fail tests. 
> This will find all the virtual thread tests which missing '/native' flag.
> 
> 1. java/lang/management/ThreadMXBean/VirtualThreads.java#default
> 
> VirtualThreads.java:223 call "invoker()" in 
> test/lib/jdk/test/lib/thread/VThreadPinner.java file, which will call the 
> native function "call".
> java/lang/management/ThreadMXBean/VirtualThreads.java#no-vmcontinuations run 
> this test with VM option "-XX:-VMContinuations" and 
> `assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for 
> custom schedulers");` will make junit skip the 
> 'testGetThreadInfoCarrierThread' unit test, so 
> 'VirtualThreads.java#no-vmcontinuations' do not need '/native' keywork.
> 
> 2. java/lang/Thread/virtual/stress/PinALot.java
> 
> PinALot.java:58 call "invoker()" in 
> test/lib/jdk/test/lib/thread/VThreadPinner.java file, which will call the 
> native function "call".
> 
> 3. java/lang/Thread/virtual/SynchronizedNative.java
> 
> Call System.loadLibrary("SynchronizedNative") at line 85.
> 
> 4. Tests java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java, 
> java/lang/Thread/virtual/ThreadAPI.java, 
> java/lang/Thread/virtual/RetryMonitorEnterWhenPinned.java, 
> java/lang/Thread/virtual/MonitorWaitNotify.java, 
> java/lang/Thread/virtual/MonitorPinnedEvents.java, 
> java/lang/Thread/virtual/MonitorEnterExit.java and other tests are similar to 
> java/lang/Thread/virtual/stress/PinALot.java
> 
> 
> - Why we need the '/native' keywork?
> 
> I usually run the tests through jtreg directively, rather than run the tests 
> through make test. If I run the test which load the native shared library 
> files and the test missing '/native' keyword but I forgot to pass the 
> '-nativepath' argument to jtreg, or pass the incorrect '-nativepath' argument 
> to jtreg, sometimes it will report timeouted after a long time, such as 
> java/lang/Thread/virtual/JfrEvents.java. If we add the missing '/native' 
> keywork, jtreg will report 'Error. Use -nativepath to specify the location of 
> native code' right away. So add the missing '/native' keyword will make run 
> the tests more friendly.
> 
> Change has been verified locally, test-fix, no risk.

This pull request has now been integrated.

Changeset: 88b4a906
Author:    SendaoYan <s...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/88b4a906d2c520ce6a7b21adc5e709067e520cdd
Stats:     55 lines in 12 files changed: 1 ins; 0 del; 54 mod

8349689: Several virtual thread tests missing /native keyword

Reviewed-by: alanb, lmesnik

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

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

Reply via email to