On Jun 5, 11:48 am, Charles Lowell <[email protected]> wrote: > Both examples were run using Java 1.6 with Sun's VM. > > On Jun 4, 9:17 pm, Rapha <[email protected]> wrote: > > > > > That looks like it's coming from a Java 5/Java 6 compatibility issue. > > Seehttps://bugzilla.mozilla.org/show_bug.cgi?id=467396 > > > Are you running Java 5? If so switching to Java 6 should fix it. > > > On May 28, 4:17 am, Charles Lowell <[email protected]> wrote: > > > > Hi there, > > > > I decided to run my application against the lastest version of rhino > > > in source, and noticed that some of the calls to overloaded java > > > functions triggered a index out of bounds exception. > > > > The following testcase works in 1.7R1 > > > > package foo; > > > > import org.mozilla.javascript.Function; > > > import org.mozilla.javascript.ContextFactory; > > > import org.mozilla.javascript.ContextAction; > > > import org.mozilla.javascript.Context; > > > import org.junit.Test; > > > > public class OverloadTest { > > > > public void method(String one, Function function) { > > > System.out.println("string+function"); > > > } > > > > public void method(String... strings) { > > > System.out.println("string[]"); > > > } > > > > @Test > > > public void callOverloadedFunction() { > > > new ContextFactory().call(new ContextAction() { > > > public Object run(Context cx) { > > > > > > cx.evaluateString(cx.initStandardObjects(),"new > > > Packages.foo.OverloadTest().method('one', 'two','three')", "<test>", > > > 1, null); > > > > > > cx.evaluateString(cx.initStandardObjects(),"new > > > Packages.foo.OverloadTest().method('one', function() {})", "<test>", > > > 1, null); > > > return null; > > > } > > > }); > > > } > > > > } > > > > //outputs: > > > string[] > > > string+function > > > > When I run it against the latest source, it results in the following > > > > string[] > > > > java.lang.ArrayIndexOutOfBoundsException: 1 > > > at org.mozilla.javascript.NativeJavaMethod.preferSignature > > > (NativeJavaMethod.java:508) > > > at org.mozilla.javascript.NativeJavaMethod.findFunction > > > (NativeJavaMethod.java:367) > > > at > > > org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java: > > > 161) > > > at > > > org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java: > > > 76) > > > at org.mozilla.javascript.gen._test__2._c_script_0(<test>:1) > > > at org.mozilla.javascript.gen._test__2.call(<test>) > > > at org.mozilla.javascript.ContextFactory.doTopCall > > > (ContextFactory.java:426) > > > at > > > org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java: > > > 3060) > > > at org.mozilla.javascript.gen._test__2.call(<test>) > > > at org.mozilla.javascript.gen._test__2.exec(<test>) > > > at > > > org.mozilla.javascript.Context.evaluateString(Context.java:1112) > > > at foo.OverloadTest$1.run(OverloadTest.java:24) > > > at org.mozilla.javascript.Context.call(Context.java:522) > > > at org.mozilla.javascript.ContextFactory.call(ContextFactory.java: > > > 535) > > > at foo.OverloadTest.callOverloadedFunction(OverloadTest.java:21) > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > > at sun.reflect.NativeMethodAccessorImpl.invoke > > > (NativeMethodAccessorImpl.java:39) > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke > > > (DelegatingMethodAccessorImpl.java:25) > > > at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall > > > (FrameworkMethod.java:44) > > > at org.junit.internal.runners.model.ReflectiveCallable.run > > > (ReflectiveCallable.java:15) > > > at org.junit.runners.model.FrameworkMethod.invokeExplosively > > > (FrameworkMethod.java:41) > > > at org.junit.internal.runners.statements.InvokeMethod.evaluate > > > (InvokeMethod.java:20) > > > at org.junit.internal.runners.statements.RunBefores.evaluate > > > (RunBefores.java:28) > > > at org.junit.internal.runners.statements.RunAfters.evaluate > > > (RunAfters.java:31) > > > at org.junit.runners.BlockJUnit4ClassRunner.runChild > > > (BlockJUnit4ClassRunner.java:73) > > > at org.junit.runners.BlockJUnit4ClassRunner.runChild > > > (BlockJUnit4ClassRunner.java:46) > > > at > > > org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) > > > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) > > > at > > > org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) > > > at org.junit.internal.runners.statements.RunBefores.evaluate > > > (RunBefores.java:28) > > > at org.junit.internal.runners.statements.RunAfters.evaluate > > > (RunAfters.java:31) > > > at org.junit.runners.ParentRunner.run(ParentRunner.java:220) > > > > bug?
I've created https://bugzilla.mozilla.org/show_bug.cgi?id=496585 for this. --N _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
