Javet icon indicating copy to clipboard operation
Javet copied to clipboard

GraalVM Native image build

Open eloyleonardo opened this issue 10 months ago • 6 comments

I'm experiencing difficulties while trying to compile Javet with GraalVM Native Image.

I followed the instructions from issues #107 and #255, setting the -Djavet.lib.loading.path and -Djavet.lib.loading.type variables during the build process. As recommended, I used the absolute path where the dynamic libraries (dylibs) are located. However, the executable fails upon running.

I have created a simple example project to illustrate the issue, available at: https://github.com/eloyleonardo/javetlab. This project uses Gradle. When I run ./gradlew test, everything works as expected. Yet, when I attempt to execute the native command (./gradlew test nativeTest), the project does not succeed and generates the following stack trace:

com.oracle.svm.core.jdk.UnsupportedFeatureError: No classes have been predefined during the image build to load from bytecodes at runtime.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:121)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.PredefinedClassesSupport.throwNoBytecodeClasses(PredefinedClassesSupport.java:76)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.PredefinedClassesSupport.loadClass(PredefinedClassesSupport.java:130)
        at [email protected]/java.lang.ClassLoader.defineClass(ClassLoader.java:274)
        at com.caoccao.javet.interop.JavetClassLoader.loadClass(JavetClassLoader.java:126)
        at com.caoccao.javet.interop.JavetClassLoader.load(JavetClassLoader.java:99)
        at com.caoccao.javet.interop.V8Host.loadLibrary(V8Host.java:418)
        at com.caoccao.javet.interop.V8Host.<init>(V8Host.java:67)
        at com.caoccao.javet.interop.V8Host.<init>(V8Host.java:43)
        at com.caoccao.javet.interop.V8Host$V8InstanceHolder.<clinit>(V8Host.java:459)
        at com.caoccao.javet.interop.V8Host.getV8Instance(V8Host.java:119)

I have been using Javet in multiples projects and find it fantastic, particularly for the quality of its documentation. Nevertheless, I am encountering difficulties with this specific case.

I would greatly appreciate any guidance or recommendations you could offer. What steps would you advise me to take next to resolve this complication?

eloyleonardo avatar Apr 29 '24 20:04 eloyleonardo