graalvm / fastr-examples

Other
60 stars 15 forks source link

Clarification for running from IDE #1

Open pranasblk opened 7 years ago

pranasblk commented 7 years ago

Dear GraalVM demo maintaners,

First of all I am happy about FastR initiative and seeing embed R in java code as future deliverable as open souce.

I did set-up the IntelliJ IDE with JDK - extract of graalvm-0.26 (root dir), added Global lib dependency graalvm-0.26/jre/lib/truffle/truffle-api.jar and source code of the fastr_javaui compiles.

But in the run-time getting service load exception: ServiceLoader.java: private S nextService() { ... if (!service.isAssignableFrom(c)) { fail(service, "Provider " + cn + " not a subtype"); } ... }

Where service is interface com.oracle.truffle.api.TruffleRuntimeAccess and c is class org.graalvm.compiler.truffle.hotspot.HotSpotTruffleRuntimeAccess

Imin:fastr_javaui pranas$ ./run.sh
Exception in thread "main" java.lang.InternalError
    at com.oracle.truffle.api.Truffle$1.run(Truffle.java:120)
    at com.oracle.truffle.api.Truffle$1.run(Truffle.java:61)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.oracle.truffle.api.Truffle.initRuntime(Truffle.java:61)
    at com.oracle.truffle.api.Truffle.<clinit>(Truffle.java:49)
    at com.oracle.truffle.api.impl.Accessor.<clinit>(Accessor.java:499)
    at com.oracle.truffle.api.vm.PolyglotEngine.ensureInitialized(PolyglotEngine.java:217)
    at com.oracle.truffle.api.vm.PolyglotEngine.<init>(PolyglotEngine.java:261)
    at com.oracle.truffle.api.vm.PolyglotEngine.<clinit>(PolyglotEngine.java:210)
    at com.oracle.truffle.r.fastrjavaui.FastRJavaUI.main(FastRJavaUI.java:104)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.oracle.truffle.api.Truffle$1.run(Truffle.java:117)
    ... 9 more
Caused by: java.util.ServiceConfigurationError: com.oracle.truffle.api.TruffleRuntimeAccess: Provider org.graalvm.compiler.truffle.hotspot.HotSpotTruffleRuntimeAccess not a subtype
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at jdk.vm.ci.services.Services.loadSingle(Services.java:147)
    ... 14 more

Can you clarify how to set-up environment to have working project?

Thanks Pranas

pranasblk commented 7 years ago

I've tried to set GRAALVM_DIR environment variable to JDK/JRE location, but both cases failed:

Would you mind considering fixing it?

steve-s commented 7 years ago

Hi pranasblk,

we've recently updated the examples to work with the latest GraalVM. You can export env variable GRAALVM_DIR pointing to GraalVM 0.28.2 location and then run ./build.sh and run.sh. For IDE development: set your JDK to GraalVM 0.28.2 and add reference to $GRAALVM_DIR/jre/lib/boot/graal-sdk.jar so that the IDE can see the Graal SDK classes, but in reality you do not need to add that jar to your class path explicitly (as you can see in build.sh and run.sh).

eginez commented 7 years ago

hey there I am trying to run the examples with 0.29 I am getting the same error: Provider org.graalvm.compiler.truffle.hotspot.HotSpotTruffleRuntimeAccess not a subtype. Any suggestions? I downloded GraalVM from the OTN website and I running the following:

PolyglotEngine eng = PolyglotEngine.newBuilder().build(); Source s = Source.newBuilder("'YES'").mimeType("text/javascript").name("one.js").build(); PolyglotEngine.Value res = eng.eval(s);

My JAVA_HOME and GRAAL_DIR are set to the graalvm directory

eginez commented 7 years ago

never mind I was missing the -Xbootclasspath parameters in my IDE configurations!. Eg: -Xbootclasspath:[path_to_truffle_api]..