As far as I understand JRuby, it is perfectly possible to use Java class inside JRuby code and vice versa, however, I still don't understand few things.
No. Ruby doesn't have annotations. The ruby2java compiler will allow you to add annotations that are used when compiling to a class file, though.
Yes:
java.util.Vector.methods.include? '[]' # => true
When embedding JRuby using BSF or JSR223? Only to the extent that those technologies allow it. When using ruby2java? Yes. It generates normal Java .class files.
I'm not exactly sure what you're asking.
Yes, you can monkey patch in JRuby, but the changes aren't visible from the Java side, just JRuby:
import java.util.Vector
class Vector
def foo
"foo!"
end
end
v = java.util.Vector.new
v.foo # => "foo!"
Plenty of little gotchas abound when using Java from JRuby. ruby2java is still in its infancy, and I'm not sure it's ready for a production environment yet. Other than that, the focus has been more on scripting with BSF and JSR223, which may or may not suit your purposes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With