Hi,
(using JRuby 1.1.6, JSR-223, and JUnit 4)
I’m trying to get a simple JRuby class inheriting from a Java base
class. For some reason I cannot call the JRuby class’ instance methods
when I inherit from the Java base class.
Here’s my JRuby code:
require “java”
JDate = java.util.Date
puts JDate.new # this line prints so no classloading issues
class Greetings < JDate
def say_hello(someones_name)
message = “Hi there #{someones_name}”
javax.swing.JOptionPane.showMessageDialog(nil, message)
end
end
Greetings.new
Here’s my JUnit test:
@Test
public void executeJRubyTask() throws Exception {
ScriptEngine engine = new
ScriptEngineManager().getEngineByName(“jruby”);
Object greetings = engine.eval(rbTaskCode);
Invocable invocable = (Invocable)engine;
System.out.println(invocable.invokeMethod(greetings,
“to_s”)); // this line succeeds printing
current timestamp
System.out.println(invocable.invokeMethod(greetings, “say_hello”,
“Ijonas”)); // this line fails when Greetings < JDate, succeeds when
JDate inherits is removed
}
Its as if JRuby “masks” the methods when I inherit Greetings from
JDate. Its not a classloading issue because both at the top of the
JRuby script as well as a call to Greetings.to_s, an uptodate date/
timestamp is printed to the console.
Any ideas ? I’m doing something obviously wrong ?
Many thanks,
Ijonas Kisselbach.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email