Closed Bug 476041 Opened 16 years ago Closed 13 years ago

overloaded var-arg java method is not found when array is provided as argument

Categories

(Rhino Graveyard :: Core, defect)

x86_64
Linux
defect
Not set
major

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Marco, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.0.5) Gecko/2008121623 Ubuntu/8.10 (intrepid) Firefox/3.0.5
Build Identifier: 1.7R1

If a Java object is accessed from within JavaScript and this object has an overloaded method with a var-arg parameter (like "Object ... objects"), the wrong method is chosen and an EvaluatorException is thrown like this:

org.mozilla.javascript.EvaluatorException: Cannot convert org.mozilla.javascript.NativeArray@3487a5cc to rhinotest.MyInterface (TestScript#1)

It worked fine until 1.6R5. It is broken in 1.7R1 and all 1.6Rx from 1.6R6 on.

I assume that is because of some specific extensions for Java var-args: It works now, if I do not pass "new Array(...)" but just put the arguments directly into the method call. However all our old scripts use the old syntax and therefore cannot be executed by the new version.

It should work with both - an explicit "new Array(...)" and with directly putting all arguments as method arguments.

Reproducible: Always

Steps to Reproduce:
See this little test case for reproducing: http://www.nightlabs.de/~marco/rhino/2009-01-29.00/RhinoTest.tar.gz
Actual Results:  
org.mozilla.javascript.EvaluatorException being thrown

Expected Results:  
Correct method being executed - no exception.
Just wanted to add: It works fine, too, if the method is not overloaded (i.e. only the var-args method exists in the Java object).
Summary: var-arg java method is not found when array is provided as argument → overloaded var-arg java method is not found when array is provided as argument
This has been fixed and works correctly in 1.7R3 and current master branch. Thanks for reporting!
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.