• Graalは言語間で呼び出しができるらしいのでお試しテスト

JavaScript -> Java

$ js
> const array = new(Java.type("int[]"))(2)
> array[1] = 1
  • 記法全然わからないけどうまくいったみたい

Ruby いれてみた

gu install ruby
Downloading: Component catalog from
Processing Component: TruffleRuby
Additional Components are required: toolchain (org.graalvm.llvm-toolchain, version 20.0.0), required by: TruffleRuby (org.graalvm.ruby)
Processing Component: toolchain
Downloading: Component ruby: TruffleRuby  from
Downloading: Component org.graalvm.llvm-toolchain: toolchain  from
Installing new component: TruffleRuby (org.graalvm.ruby, version 20.0.0)
Installing new component: toolchain (org.graalvm.llvm-toolchain, version 20.0.0)

The Ruby openssl C extension needs to be recompiled on your system to work with the installed libssl.
First, make sure TruffleRuby's dependencies are installed, which are described at:
Then run the following command:

Set of GraalVM components that provide language implementations have changed. The Polyglot native image and polyglot native C library may be out of sync:
- new languages may not be accessible
- removed languages may cause the native binary to fail on missing resources or libraries.
To rebuild and refresh the native binaries, use the following command:
        /usr/local/graalvm-ce/bin/gu rebuild-images
$ ruby -v
truffleruby 20.0.0, like ruby 2.6.5, GraalVM CE Native [x86_64-linux]
array = Polyglot.eval('js', '[1,2,3,4]');
puts array[2];
  • 実行
$ ruby --polyglot --jvm test.rb

Polyglot って何?

  • GrralVm上のTruffleRubyでは Polyglot.eval() メソッドに言語のidと実行するコードを渡して実行する
  • 実行時には --polyglot --jvm のようにオプションをつける