Hi -
This is stupid, but it’s baffling the hell out of me. I have a Java
class:
package javatest;
public class Test {
public void sayHi() { System.out.println(“Hello.”); }
}
And I have a JRuby file:
require ‘java’
include_class ‘javatest.Test’
This works.
jt = Test.new
jt.sayHi
This works
class MyList < java.util.ArrayList
def say_hi
puts “hi”
end
end
ml = MyList.new
ml.say_hi
This works too! Re-opening javatest.Test
class Test
def sayOuch
puts “Ouch!”
end
end
t = Test.new
t.sayHi
t.sayOuch
So why doesn’t this work?!
class ExtendedClass < Test
def sayOuch
puts “Ouch!”
end
end
ec = ExtendedClass.new
ec.sayOuch
Here’s (part of) the error:
JavaProxyClassFactory.java:779:in
org.jruby.javasupport.proxy.JavaProxyClassFactory.validateArgs': java.lang.IllegalArgumentException: cannor add classes to package javatest (NativeException) from JavaProxyClassFactory.java:163:in
org.jruby.javasupport.proxy.JavaProxyClassFactory.newProxyClass’
from JavaProxyClass.java:111:in
org.jruby.javasupport.proxy.JavaProxyClass.getProxyClass' from JavaProxyClass.java:662:in
org.jruby.javasupport.proxy.JavaProxyClass.get_with_class’
from null:-1:in
org.jruby.javasupport.proxy.JavaProxyClassInvoker$get_with_class_FS1.call' from FastInvocationCallback.java:55:in
org.jruby.runtime.callback.FastInvocationCallback.execute’
from SimpleCallbackMethod.java:70:in
org.jruby.internal.runtime.methods.SimpleCallbackMethod.call' from CallSite.java:153:in
org.jruby.runtime.CallSite$ICNonBlockCallSite.call’
from CallSite.java:100:in
`org.jruby.runtime.CallSite$ArgumentBoxingCallSite.call’
… 47 levels…
I’m using JRuby 1.1rc, Leopard w/ Java 1.5. I’m really baffled here -
I’ve tried to find an answer, but have come up with nothing. What am I
doing wrong?
Help is appreciated.
Thanks,
Shane