I am having trouble trying to extend a non-abstract (though non-final)
java class. I get the following exception from JRuby:
Exception in thread “main” java.lang.RuntimeException: java_object
returned null for NewEdge
The object has a constructor that takes two arguments. Due to the
bug/feature that the number of arguments in the ruby class must be the
same as the number of arguments in the java class I am also overriding
self.new. Note that the types of asset1 and asset2 are java types of
the same type expected by the java ctor.
So in Java I have a class called Edge and in Ruby:
class NewEdge < Pairs::Edge
def initialize(asset1,asset2) @asset1, @asset2 = asset1, asset2 @passed = true end def self.new(asset1, asset2, ranges, mincor, maxadf) obj = self.allocate obj.send :initialize, asset1, asset2 obj.instance_variable_set(:@ranges, ranges) obj.instance_variable_set(:@mincor, mincor) obj.instance_variable_set(:@maxadf, maxadf) puts "created object", obj obj end ...
The new object is being passed back to java, at which point the above
exception occurs. Why would convertRubyToJava ever fail? On another
note I do hope that the ctor issue is resolved as well at some point.
Writing self.new factories are ugly.