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.
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