jruby « cast « Java Data Type Q&A





1. Casting Java Objects From JRuby    stackoverflow.com

I'm working with a Java library in JRuby. I'm reading an object from a file, and I need to pass it as a different object type to a second constructor:

@hmm_model ...

2. Casting objects in JRuby    stackoverflow.com

Is there a way I can explicitly cast one Java object to another Java class from JRuby? Sometimes I want to be able to invoke SomeJavaClass#aMethod(MySuperClass) rather than SomeJavaClass#aMethod(MyClass) from ...

3. Casting objects in JRuby    stackoverflow.com

I still don't feel like this is adequately answered. how does one do this in jruby:

MyClass myobj = new MyClass;
InheritsFromMyClass changedobj = (InheritsFromMyClass)myobj;

4. Dereferencing / Casting in jruby    stackoverflow.com

I am deserializing a Java object in jruby [1]. The object returns two values, foo and bar:

puts foo
[Ljava.lang.Object;@211c7f8d
puts bar
[Ljava.lang.Class;@673ceab3
bar contains the Java type (e.g. for this instance it's java.util.List) for foo. ...