@@ -49,23 +49,27 @@ public void afterRegistration(AfterRegistrationAccess access) {
4949 if (Continuation .isSupported ()) {
5050 VirtualThreads impl ;
5151 if (LoomSupport .isEnabled ()) {
52- impl = new LoomVirtualThreads ();
52+ try {
53+ impl = (VirtualThreads ) Class .forName ("com.oracle.svm.core.jdk19.LoomVirtualThreads" ).getDeclaredConstructor ().newInstance ();
54+ } catch (Exception e ) {
55+ throw UserError .abort (e , "Error initializing LoomVirtualThreads" );
56+ }
5357 } else {
5458 /*
5559 * GR-37518: ForkJoinPool on 11 syncs on a String which doesn't have its own monitor
5660 * field, and unparking a virtual thread in additionalMonitorsLock.unlock causes a
5761 * deadlock between carrier thread and virtual thread. 17 uses a ReentrantLock.
5862 */
5963 UserError .guarantee (JavaVersionUtil .JAVA_SPEC >= 17 , "Continuations (%s) are currently supported only on JDK 17 and later." ,
60- SubstrateOptionsParser .commandArgument (SubstrateOptions .SupportContinuations , "+" ));
64+ SubstrateOptionsParser .commandArgument (SubstrateOptions .SupportContinuations , "+" ));
6165
6266 impl = new SubstrateVirtualThreads ();
6367 }
6468 ImageSingletons .add (VirtualThreads .class , impl );
6569 } else {
6670 UserError .guarantee (!SubstrateOptions .UseLoom .getValue (), "%s cannot be enabled without option %s." ,
67- SubstrateOptionsParser .commandArgument (SubstrateOptions .UseLoom , "+" ),
68- SubstrateOptionsParser .commandArgument (SubstrateOptions .SupportContinuations , "+" ));
71+ SubstrateOptionsParser .commandArgument (SubstrateOptions .UseLoom , "+" ),
72+ SubstrateOptionsParser .commandArgument (SubstrateOptions .SupportContinuations , "+" ));
6973 }
7074 }
7175
@@ -77,7 +81,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
7781 }
7882
7983 access .registerReachabilityHandler (a -> access .registerAsInHeap (StoredContinuation .class ),
80- ReflectionUtil .lookupMethod (StoredContinuationAccess .class , "allocate" , int .class ));
84+ ReflectionUtil .lookupMethod (StoredContinuationAccess .class , "allocate" , int .class ));
8185
8286 if (LoomSupport .isEnabled ()) {
8387 RuntimeReflection .register (ReflectionUtil .lookupMethod (ForkJoinPool .class , "compensatedBlock" , ForkJoinPool .ManagedBlocker .class ));
@@ -90,8 +94,8 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
9094 static void abortIfUnsupported () {
9195 if (!Continuation .isSupported ()) {
9296 throw UserError .abort ("Continuation support is used, but not enabled. Use options %s or %s." ,
93- SubstrateOptionsParser .commandArgument (SubstrateOptions .SupportContinuations , "+" ),
94- SubstrateOptionsParser .commandArgument (SubstrateOptions .UseLoom , "+" ));
97+ SubstrateOptionsParser .commandArgument (SubstrateOptions .SupportContinuations , "+" ),
98+ SubstrateOptionsParser .commandArgument (SubstrateOptions .UseLoom , "+" ));
9599 }
96100 }
97101}
0 commit comments