[jdk21u-dev] RFR: 8375001: NativeThreadSet get wrong currentNativeThread when using virtual thread
Severin Gehwolf
sgehwolf at openjdk.org
Tue Jan 13 14:39:25 UTC 2026
On Mon, 12 Jan 2026 09:48:23 GMT, Jiawei Tang <jwtang at openjdk.org> wrote:
> 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?
This should probably fixed with a backport of https://bugs.openjdk.org/browse/JDK-8321594 instead.
-------------
PR Comment: https://git.openjdk.org/jdk21u-dev/pull/2542#issuecomment-3744687969
More information about the jdk-updates-dev
mailing list