简体   繁体   中英

JRuby and Java objects

Please tell me if it is possible to do the following:

  • create an instance of a specific class in Java
  • pass it to JRuby to do something with it
  • continue using the "modified" version in Java

May you provide a small working example?

EDIT: It turns out that embedding was the simplest way to achieve this. More information is available on Embedding JRuby .

Yes it's possible. This page on the JRuby wiki should get you started.

这是我使用的解决方案: 直接JRuby嵌入

It depends on what you mean by "do something". If you mean "redefine a method", then the answer is no, not really. The new method will be used by jruby, but any calls to the method in java will continue to invoke the old method.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM