If I have a Ruby
script executed by ScriptingContainer
of JRuby
in my Java
application, is the Ruby
script capable of accessing or making use of a class I have defined in my Java
application if I haven't shared anything with the script ?
By sharing this is what I mean:
ruby = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
ruby.put("main", MyClass.class);
ruby.runScriptlet(readFile("Test.rb"));
As you can see, I am sharing with the Ruby
script a variable called main, whose value is MyClass.class
.
If I don't share anything , is the Ruby
script still capable of using MyClass
in my application?
是的,根据我的回答 :如果MyClass
在你的类路径/ $LOAD_PATH
,JRuby会在你java_import
时把它拿起来。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.