oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.26k stars 1.62k forks source link

[GR-57324] NoClassDefFoundError: com.oracle.svm.core.c.function.CEntryPointNativeFunctions #8851

Open JiangWork opened 4 months ago

JiangWork commented 4 months ago

Hi, Team.

I am writing following code to use detachAllThreadsAndTearDownIsolate function.

@CEntryPoint(name = "Java_com_paypal_risk_engine_shared_HeapNativeImageAccess_detachAllAndTearDownIsolate")
//    @CEntryPointOptions(prologue = CEntryPointOptions.NoPrologue.class, epilogue = CEntryPointOptions.NoEpilogue.class)
    public static int detachAllAndTearDownIsolate(JNI.JNIEnv jniEnv, Pointer clazz, @CEntryPoint.IsolateThreadContext long isolateId, IsolateThread isolateThreadId) {
        System.out.println("detachAllAndTearDownIsolate>>");
        try {
            return CEntryPointNativeFunctions.detachAllThreadsAndTearDownIsolate(isolateThreadId);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            throw throwable;
        }
    }

I can successfully build the shared so file. But when i call this method, it will throw exception:

java.lang.NoClassDefFoundError: com.oracle.svm.core.c.function.CEntryPointNativeFunctions
    at com.paypal.risk.engine.shared.HeapNativeImageShared.detachAllAndTearDownIsolate(HeapNativeImageShared.java:58)

Any idea?

oubidar-Abderrahim commented 4 months ago

Thanks for raising this, @JiangWork . Unfortunately, the information that you have provided is not sufficient for us to determine what is going wrong in your application. could you please share some details:

What version of GraalVM you're using? what OS and architecture? Do you collect the Metadata for your application as mentioned here: https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/ Finally can you share a complete reproducer to this issue?

JiangWork commented 4 months ago

hi, @oubidar-Abderrahim

The graalvm version is: graalvm-jdk-21.0.1+12.1 Os: macos

I have attached simple project code, reproduce step:

  1. mvn clean package
  2. native-image -jar target/native-expr-0.1-jar-with-dependencies.jar --shared -H:Name=libnativeimpl
  3. then run: Native.class

And output will be like: Hello 0 detachAllAndTearDownIsolate>>

java.lang.NoClassDefFoundError: com.oracle.svm.core.c.function.CEntryPointNativeFunctions
    at org.graalvm.nativeimage.expr.impl.NativeImpl.detachAllAndTearDownIsolate(NativeImpl.java:37)
java.lang.NoClassDefFoundError: com.oracle.svm.core.c.function.CEntryPointNativeFunctions
    at org.graalvm.nativeimage.expr.impl.NativeImpl.detachAllAndTearDownIsolate(NativeImpl.java:37)

Attachment: java.zip

oubidar-Abderrahim commented 2 months ago

Please upload your code in a github repo and share the link to clone it, Thank you