Closed
Bug 496585
Opened 15 years ago
Closed 15 years ago
Regression in overload resolution
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: norrisboyd, Assigned: norrisboyd)
Details
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?
Assignee | ||
Comment 1•15 years ago
|
||
Checking in src/org/mozilla/javascript/NativeJavaMethod.java; /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeJavaMethod.java,v <- - NativeJavaMethod.java new revision: 1.65; previous revision: 1.64 done RCS file: /cvsroot/mozilla/js/rhino/testsrc/doctests/467396.doctest,v done Checking in testsrc/doctests/467396.doctest; /cvsroot/mozilla/js/rhino/testsrc/doctests/467396.doctest,v <-- 467396.doctest initial revision: 1.1 done RCS file: /cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/Bug4965 85.java,v done Checking in testsrc/org/mozilla/javascript/tests/Bug496585.java; /cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/Bug496585.java,v <-- Bug496585.java initial revision: 1.1 done
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•