Skip to content

Commit eda3fc3

Browse files
committed
Minor style improvements.
1 parent ac8e28b commit eda3fc3

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public void afterRegistration(AfterRegistrationAccess access) {
5454
VMError.guarantee(JavaVersionUtil.JAVA_SPEC >= 19);
5555
ImageSingletons.add(VirtualThreads.class, new LoomVirtualThreads());
5656
} else if (JavaVersionUtil.JAVA_SPEC == 17) {
57+
ImageSingletons.add(VirtualThreads.class, new SubstrateVirtualThreads());
58+
} else {
5759
/*
58-
* GR-37518: ForkJoinPool on 11 syncs on a String which doesn't have its own monitor
60+
* GR-37518: on 11, ForkJoinPool syncs on a String which doesn't have its own monitor
5961
* field, and unparking a virtual thread in additionalMonitorsLock.unlock causes a
6062
* deadlock between carrier thread and virtual thread. 17 uses a ReentrantLock.
6163
*/
62-
ImageSingletons.add(VirtualThreads.class, new SubstrateVirtualThreads());
63-
} else {
6464
throw UserError.abort("Continuations are currently supported only on JDK 17 with option %s, or on JDK 19 with preview features enabled (-J--enable-preview).",
6565
SubstrateOptionsParser.commandArgument(SubstrateOptions.SupportContinuations, "+"));
6666
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/LoomVirtualThreads.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@
4242
import com.oracle.svm.core.util.VMError;
4343

4444
/**
45-
* In a Project Loom JDK, code specific to virtual threads is part of the {@link Thread} methods,
46-
* e.g. {@code yield} or {@code sleep}, and the implementation for platform threads is generally in
47-
* methods named {@code yield0} or {@code sleep0}, so we only substitute that platform thread code
48-
* in {@link Target_java_lang_Thread}, and generally do not expect these methods to be reachable.
45+
* In a JDK that supports Project Loom virtual threads (JEP 425, starting with JDK 19 as preview
46+
* feature), code specific to virtual threads is part of {@link Thread} methods, e.g. {@code yield}
47+
* or {@code sleep}, and the implementation for platform threads is generally in methods named
48+
* {@code yield0} or {@code sleep0}, so we only substitute that platform thread code in
49+
* {@link Target_java_lang_Thread}, and do not expect several methods here to be reachable.
4950
*
5051
* @see <a href="https://openjdk.java.net/projects/loom/">Project Loom (Wiki, code, etc.)</a>
5152
*/
@@ -200,7 +201,7 @@ private static StackTraceElement[] asyncGetStackTrace(Target_java_lang_VirtualTh
200201
return stackTrace;
201202
}
202203

203-
private static StackTraceElement[] asyncMountedGetStackTrace(@SuppressWarnings("unused") Target_java_lang_VirtualThread thread) {
204+
private static StackTraceElement[] asyncMountedGetStackTrace(Target_java_lang_VirtualThread thread) {
204205
return StackTraceUtils.asyncGetStackTrace(Thread.class.cast(thread));
205206
}
206207

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@
105105
* @see JavaThreads
106106
*/
107107
public abstract class PlatformThreads {
108-
private static final Field FIELDHOLDER_STATUS_FIELD = (!ImageInfo.inImageCode() || JavaVersionUtil.JAVA_SPEC < 19) ? null
109-
: ReflectionUtil.lookupField(Target_java_lang_Thread_FieldHolder.class, "threadStatus");
110-
private static final Field THREAD_STATUS_FIELD = (!ImageInfo.inImageCode() || JavaVersionUtil.JAVA_SPEC >= 19) ? null
111-
: ReflectionUtil.lookupField(Target_java_lang_Thread.class, "threadStatus");
108+
private static final Field FIELDHOLDER_STATUS_FIELD = (JavaVersionUtil.JAVA_SPEC >= 19 && ImageInfo.inImageCode())
109+
? ReflectionUtil.lookupField(Target_java_lang_Thread_FieldHolder.class, "threadStatus")
110+
: null;
111+
private static final Field THREAD_STATUS_FIELD = (JavaVersionUtil.JAVA_SPEC < 19 && ImageInfo.inImageCode())
112+
? ReflectionUtil.lookupField(Target_java_lang_Thread.class, "threadStatus")
113+
: null;
112114

113115
@Fold
114116
public static PlatformThreads singleton() {

0 commit comments

Comments
 (0)