Ziqi Liu
Ziqi Liu

Reputation: 3171

package com.oracle.svm.core doesn't exist

I was something related to graal and so I need to use com.oracle.svm.core.annotate.* in my code. My compiler is complaining package com.oracle.svm.core.annotate does not exist

I was using graalvm-java11 sdk, the compiling log is also showing that it's using the right sdk

Compiling with toolchain '/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home'.
Compiling with JDK Java compiler API.

more about my env:

➜  map-java-service git:(master) ✗echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home
➜  map-java-service git:(master) ✗ which java
/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/bin/java

I thought this would be by default include, is there anything else I need to configure before I can use com.oracle.svm.core?

Added: I've installed native-image

➜  ~ native-image --version
GraalVM 21.1.0 Java 11 CE (Java Version 11.0.11+8-jvmci-21.1-b05)

Upvotes: 3

Views: 607

Answers (1)

Kangaroos In Antarctica
Kangaroos In Antarctica

Reputation: 1350

I solved this issue by adding the org.graalvm.nativeimage:svm dependency, for example in pom.xml:

<dependencies>
    ...
    <dependency>
        <groupId>org.graalvm.nativeimage</groupId>
        <artifactId>svm</artifactId>
        <version>24.1.1</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

As I understand, this should build with any Java version after that, but the feature will only work with native image build after GraalVM version 22.3, see @TargetClass

Upvotes: 1

Related Questions