New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build steps for embedding graalvm #550

Closed
oobles opened this Issue Jul 16, 2018 · 2 comments

Comments

2 participants
@oobles
Copy link

oobles commented Jul 16, 2018

Is it possible to embedd graaljs or other graal based language into a JVM project?

We have a large JVM based project that currently uses Nashorn. It would be useful to allow execution of R or Python code via graal in the project. Is it possible to bring these other languages into a JVM project, or do we effectively switch tool chain?

Looking at graaljs for instance, it isn't possible to bring in the related libraries via something like gradle.

graalvm/graaljs#17

So, would I be correct in saying the development process would be:

  1. Import graal-sdk via gradle from maven ( https://mvnrepository.com/artifact/org.graalvm/graal-sdk)
  2. Develop code to execute graalvm code via the org.graalvm.proxy packages.
    (Limited test case capability because project would not have access to actual languages)
  3. Compile to JAR and package using normal jdk8 via gradle.
  4. Execute the compiled java code using graalvm with R, Python, JavaScript installed.
@chumer

This comment has been minimized.

Copy link
Member

chumer commented Jul 19, 2018

Thanks a lot for your excellent questions.

Yes that is one way of using GraalVM, if you want to develop with a normal JDK. If you configure GraalVM as your default JDK in your IDE of choice it will pick up Graal-SDK automatically. So step (1) would not be needed and you would have access to the languages in your test cases. You can also run Gradle with GraalVM.

We are currently investigating how we can nicely deploy Graal.js + Graal on Maven so we can execute it on a normal JDK 11 as well. This should make it easier for certain people to migrate from Nashorn. Note that we don't plan to deploy Python, Ruby or Node.js this way, so you will need GraalVM for that.

For production deployments you might also want to consider creating a native image of your Java application + R/Python/JavaScript.

Just today @wirthi published a blog post about migrating from Nashorn[1]. Please also see our Nashorn migration guide[2].

Hope this was helpful. Feel free to close if you have no further questions.

[1] https://medium.com/graalvm/oracle-graalvm-announces-support-for-nashorn-migration-c04810d75c1f
[2] https://github.com/graalvm/graaljs/blob/master/docs/user/NashornMigrationGuide.md

@chumer chumer self-assigned this Jul 19, 2018

@chumer chumer added the question label Jul 19, 2018

@oobles

This comment has been minimized.

Copy link
Author

oobles commented Jul 20, 2018

Thanks, that clarifies it for me. I also found the following article on InfoQ very useful[1].

I like the idea of creating native images for our applications, however, we make use of dynamic byte code generation and reflection via MethodHandles. This is integrated with Nashorn to create a dynamic execution environment. Unfortunately, the wording in limitiations[2], suggests there's no plan to support this in the near future.

[1] https://www.infoq.com/articles/Graal-Java-JIT-Compiler
[2] https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md

@oobles oobles closed this Jul 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment