oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
3.02k stars 185 forks source link

Support to modify Java classpath at run-time #2693

Closed drianpauL closed 2 years ago

drianpauL commented 2 years ago

From: https://graalvm.slack.com/archives/CMY63522F/p1658321203861729

When running TruffleRuby in JVM mode (--jvm), it would be nice to have a convenient method modify the JVM classpath at run-time.

An example use case for this would be for a Ruby gem (managed via Bundler) that loads a Java library. Currently users of that gem would need to supply additional environment or command-line options at start time: e.g. --vm.classpath=/graalvm/languages/ruby/lib/gems/gems/some-ruby-gem-1.0.0/some-java-lib.jar (in addition to specifying the gem version in a Gemfile) . It would be much more convenient if the Ruby gem could update the classpath itself when it was loaded.


NB: @woess and @eregon mentioned that GraalJS has a built-in function: Java.addToClasspath https://github.com/oracle/graaljs/blob/3e4d6a7520ed514c756242a6618357138499576c/graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/builtins/JavaBuiltins.java#L656-L678

bjfish commented 2 years ago

@drianpauL This is now added at https://github.com/oracle/truffleruby/commit/925274f409f8498c985b2a23d26cf21f5597483a. Thank you for reporting this.