|
25 | 25 | package com.oracle.svm.core.classinitialization; |
26 | 26 |
|
27 | 27 | // Checkstyle: stop |
| 28 | + |
28 | 29 | import java.util.concurrent.locks.Condition; |
29 | 30 | import java.util.concurrent.locks.ReentrantLock; |
30 | 31 |
|
31 | | -import com.oracle.svm.core.jdk.InternalVMMethod; |
32 | 32 | import org.graalvm.compiler.serviceprovider.GraalUnsafeAccess; |
33 | 33 | import org.graalvm.nativeimage.Platform; |
34 | 34 | import org.graalvm.nativeimage.Platforms; |
35 | 35 | import org.graalvm.nativeimage.c.function.CFunctionPointer; |
36 | 36 |
|
37 | 37 | import com.oracle.svm.core.annotate.InvokeJavaFunctionPointer; |
38 | 38 | import com.oracle.svm.core.hub.DynamicHub; |
| 39 | +import com.oracle.svm.core.jdk.InternalVMMethod; |
39 | 40 | import com.oracle.svm.core.snippets.SubstrateForeignCallTarget; |
| 41 | +import com.oracle.svm.core.util.VMError; |
40 | 42 |
|
41 | 43 | import sun.misc.Unsafe; |
42 | 44 | // Checkstyle: resume |
@@ -294,7 +296,7 @@ private static void initialize(ClassInitializationInfo info, DynamicHub hub) { |
294 | 296 | Throwable exception = null; |
295 | 297 | try { |
296 | 298 | /* Step 9: Next, execute the class or interface initialization method of C. */ |
297 | | - info.invokeClassInitializer(); |
| 299 | + info.invokeClassInitializer(hub); |
298 | 300 | } catch (Throwable ex) { |
299 | 301 | exception = ex; |
300 | 302 | } |
@@ -372,9 +374,17 @@ private void setInitializationStateAndNotify(InitState state) { |
372 | 374 | } |
373 | 375 | } |
374 | 376 |
|
375 | | - private void invokeClassInitializer() { |
| 377 | + private void invokeClassInitializer(DynamicHub hub) { |
376 | 378 | if (classInitializer != null) { |
377 | | - ((ClassInitializerFunctionPointer) classInitializer.functionPointer).invoke(); |
| 379 | + ClassInitializerFunctionPointer functionPointer = (ClassInitializerFunctionPointer) classInitializer.functionPointer; |
| 380 | + if (functionPointer.isNull()) { |
| 381 | + throw invokeClassInitializerError(hub); |
| 382 | + } |
| 383 | + functionPointer.invoke(); |
378 | 384 | } |
379 | 385 | } |
| 386 | + |
| 387 | + private static RuntimeException invokeClassInitializerError(DynamicHub hub) { |
| 388 | + throw VMError.shouldNotReachHere("No classInitializer.functionPointer for class " + hub.getName()); |
| 389 | + } |
380 | 390 | } |
0 commit comments