Closed Bug 11077 Opened 26 years ago Closed 26 years ago

ScriptableObject.defineFunctionProperties() uses invalid signature check.

Categories

(Core :: JavaScript Engine, defect, P3)

Other
Windows 98
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: time, Assigned: norrisboyd)

Details

If I use the method ScriptableObject.defineFunctionProperties(), in a package that is outside of the org.mozilla.javascript package, then the signature for my native methods that I wish to make into functions looks like this: public void kp.tcib.ctsadmin.JScriptor.include ( org.mozilla.javascript.Context, org.mozilla.javascript.Scriptable, java.lang.Object[], org.mozilla.javascript.Function ) YET, defineFunctionProperties() makes a validity check for a signature that looks like this: public void kp.tcib.ctsadmin.JScriptor.include ( Context, Scriptable, Object[], Function ) Which fails, and thus I am unable to use the method defineFunctionProperties() even though the method has the correct signature.
The bug occurs with the 'tip' release, as well as 1.4. It appears that the actual signature check is in FunctionObject.
Assignee: mccabe → norris
Reassigning to norris.
Status: NEW → ASSIGNED
I don't guess I understand the problem. In org.mozilla.javascript.tools.shell.Main (i.e., not in org.mozilla.javascript), defineFunctionProperties is used to define the "print" property, which is defined with the signature public static Object print(Context cx, Scriptable thisObj, Object[] args, Function funObj) So if I change that signature to public static Object print(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, java.lang.Object[] args, org.mozilla.javascript.Function funObj) (which should result in identical compiled code, right?), everything still compiles and runs. What am I missing here?
Here is my method definition: public void include( org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj ) In public class JScriptor, which extends Object. This is the call I make to define the function: String[] preDefNames = { "include" }; ((ScriptableObject) this.jScope).defineFunctionProperties ( preDefNames, JScriptor.class, ScriptableObject.DONTENUM ); This call to defineFunctionProperties() produces this exception: org.mozilla.javascript.EvaluatorException: Variable arguments signature must be (Context cx, Scriptable thisObj, Object[] args, Function funObj) to define a function. at kp.tcib.ctsadmin.JScriptor$CTSErrorReporter.runtimeError (JScriptor.java:488) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:390) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:406) at org.mozilla.javascript.FunctionObject.<init>(FunctionObject.java:131) at org.mozilla.javascript.ScriptableObject.defineFunctionProperties (ScriptableObject.java:1136) at kp.tcib.ctsadmin.JScriptor.runContextScript(JScriptor.java:274) Where JScriptor.java:274 is the call to defineFunctionProperties(). I will see if I can make a small reproducable application. tim.
Ah! The method needs to be defined as static. Sorry for the bad error message--I'll fix Rhino to print a good one.
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Fixed in tip: Checking in FunctionObject.java; /cvsroot/mozilla/js/rhino/org/mozilla/javascript/FunctionObject.java,v <-- Fun ctionObject.java new revision: 1.5; previous revision: 1.4 done Checking in ScriptableObject.java; /cvsroot/mozilla/js/rhino/org/mozilla/javascript/ScriptableObject.java,v <-- S criptableObject.java new revision: 1.8; previous revision: 1.7 done Checking in resources/Messages.properties; /cvsroot/mozilla/js/rhino/org/mozilla/javascript/resources/Messages.properties,v <-- Messages.properties new revision: 1.5; previous revision: 1.4 done
You need to log in before you can comment on or make changes to this bug.