[jdk21u-dev] RFR: 8375001: NativeThreadSet get wrong currentNativeThread when using virtual thread
Jiawei Tang
jwtang at openjdk.org
Mon Jan 12 09:55:55 UTC 2026
Hi, I create an issue in the bug system: https://bugs.openjdk.org/browse/JDK-8375001
`NativeThread.currentNativeThread();` should be replaced by `NativeThread.current();`. Otherwise, when using virtual thread, the program will run into a wrong state.
Now, I just changed the function used in NativeTheadSet.java, but I did not delete the `currentNativeThread` in `src/java.base/unix/classes/sun/nio/ch/NativeThread.java` and `src/java.base/windows/classes/sun/nio/ch/NativeThread.java` . I am wondering if I should delete these functions since they are useless now. I hope to get some advice. Thank you!
Besides, the jtreg testcases which can produce this issue is from JDK-8310902 (with option: `-testThreadFactory:Virtual -testThreadFactoryPath:./jtregTestThreadFactory.jar`). Do I need to bring the testcase `test/jdk/java/nio/channels/FileChannel/CloseDuringTransfer.java` here?
-------------
Commit messages:
- 8375001: NativeThreadSet get wrong currentNativeThread when using virtual thread
Changes: https://git.openjdk.org/jdk21u-dev/pull/2542/files
Webrev: https://webrevs.openjdk.org/?repo=jdk21u-dev&pr=2542&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8375001
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk21u-dev/pull/2542.diff
Fetch: git fetch https://git.openjdk.org/jdk21u-dev.git pull/2542/head:pull/2542
PR: https://git.openjdk.org/jdk21u-dev/pull/2542
More information about the jdk-updates-dev
mailing list