Exception thrown from jruby when attempting to extend java class


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
at org.jruby.javasupport.JavaUtil.convertRubyToJava(JavaUtil.java:825)

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

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




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.



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs