Closed
Bug 461138
Opened 16 years ago
Closed 16 years ago
Setter for a Scriptable on host object doesn't accept null value
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: mguillemot, Unassigned)
References
Details
Attachments
(1 file, 1 obsolete file)
3.03 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092510 Ubuntu/8.04 (hardy) Firefox/3.0.3 Build Identifier: When defining a setter on an host object for a field that implements Scriptable, Rhino throws EcmaError org.mozilla.javascript.EcmaError: TypeError: Cannot convert null to an object. when trying to assign null value. A workaround consists in changing the signature of the setter to accept java.lang.Object instead of the desired Scriptable, but it is not pleasant. Reproducible: Always Steps to Reproduce: 1. 2. 3.
Comment 3•16 years ago
|
||
Just use ScriptRuntime.toObjectOrNull(). The only drawback is a potential extra call to ScriptRuntime.getTopCallScope() because toObjectOrNull doesn't take a scope argument, but I think that's acceptable for the simplified code.
Attachment #344266 -
Attachment is obsolete: true
Comment 4•16 years ago
|
||
Checking in src/org/mozilla/javascript/FunctionObject.java; /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/FunctionObject.java,v <-- FunctionObject.java new revision: 1.82; previous revision: 1.81 done RCS file: /cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/CustomSetterAcceptNullScriptableTest.java,v done Checking in testsrc/org/mozilla/javascript/tests/CustomSetterAcceptNullScriptableTest.java; /cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/CustomSetterAcceptNullScriptableTest.java,v <-- CustomSetterAcceptNullScriptableTest.java initial revision: 1.1 done
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
I don't know if it matters here but getTopCallScope(Context) is evil when many scopes are involved, I wouldn't use it at all when an other solution is possible. Here we have a scope available, this information shouldn't be lost.
You need to log in
before you can comment on or make changes to this bug.
Description
•