You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is still a bug if classes are defined package-protected.
Here is my test-class (tested with Windows XP, RUBY_VERSION 1.9.3, JRUBY_VERSION 1.7.9, Java 1.7)
importjavax.script.ScriptContext;
importjavax.script.ScriptEngine;
importjavax.script.ScriptEngineManager;
importorg.testng.annotations.Test;
/** * Tests some problems with overloaded or added methods in extended, package-protected classes. * The tests will fail until the Impl-classes will be declared as public. */@TestpublicclassJRuby6087Test
{
publicstaticinterfaceMyInterface
{
voidsayHello(Stringname);
}
staticfinalclassOverloadedImplimplementsMyInterface
{
publicvoidsayHello(Stringname)
{
System.out.println("hello " + name);
}
publicvoidsayHello(Stringname, Stringsurname)
{
System.out.println("hello " + name + " " + surname);
}
}
staticfinalclassNewMethodImplimplementsMyInterface
{
publicvoidsayHello(Stringname)
{
System.out.println("hello " + name);
}
publicvoidbye()
{
System.out.println("bye bye");
}
}
publicstaticclassProvider
{
publicMyInterfacegetOverloadedImpl()
{
returnnewOverloadedImpl();
}
publicMyInterfacegetNewMethodImpl()
{
returnnewNewMethodImpl();
}
}
publicvoidtestOverloadedMethod()
throwsException
{
System.out.println("JRuby6087Test.testOverloadedMethod()");
finalScriptEnginee = newScriptEngineManager().getEngineByName("ruby");
e.getContext().setAttribute("o", newProvider(), ScriptContext.GLOBAL_SCOPE);
finalStringBuilderscript = newStringBuilder();
script.append("$o.overloadedImpl.sayHello('Al')\n");
// reflection worksscript.append("$o.overloadedImpl.java_method('sayHello', [java.lang.String, java.lang.String]).call('this', 'works')\n");
// normal call does notscript.append("$o.overloadedImpl.sayHello('this', 'works not')\n");
e.eval(script.toString());
}
publicvoidtestNewMethod()
throwsException
{
System.out.println("JRuby6087Test.testNewMethod()");
finalScriptEnginee = newScriptEngineManager().getEngineByName("ruby");
e.getContext().setAttribute("o", newProvider(), ScriptContext.GLOBAL_SCOPE);
finalStringBuilderscript = newStringBuilder();
script.append("$o.newMethodImpl.sayHello('Al')\n");
// reflection worksscript.append("$o.newMethodImpl.java_method('bye', []).call()\n");
// normal call does not script.append("$o.newMethodImpl.bye()\n");
e.eval(script.toString());
}
}
See here: http://jira.codehaus.org/plugins/servlet/mobile#issue/JRUBY-6087
The text was updated successfully, but these errors were encountered: