Closed
Bug 215923
Opened 22 years ago
Closed 22 years ago
too shallow search for "this" when calling reflected Java methods
Categories
(Rhino Graveyard :: Core, defect)
Rhino Graveyard
Core
Tracking
(Not tracked)
RESOLVED
FIXED
1.5R5
People
(Reporter: igor, Assigned: norrisboyd)
Details
Attachments
(1 file)
When a prototype chain contains more then one wrapped Java object obtained
through Context.toObject(), Rhino uses the first Java object as Java "this" when
scripts calls methods found in other objects.
For example, the following code:
var proto1 = java.lang.Integer(1);
var proto2 = java.lang.Boolean(false);
proto2.__proto__ = proto1;
var o = { __proto__: proto2 };
var ok = (false == o.booleanValue());
ok = ok && (1 == o.intValue());
print(ok);
throws an exception when it applies () to "o.intValue" instead of printing
"true" at the end. It happens because during evaluating of "o.intValue()"
intValue is located in Integer and then it is applied to a Boolean instance.
This is rather inconsistent since Rhino should either not to look for prototype
chain for Java this (so o.booleanValue() should fail) or look all the whole
prototype chain until it finds one. The first behavior is restrictive even if
adheres better to semantics of JS function calls while the second allows to
build a prototype chain of Java objects to expose all their methods in a
convenient way.
Reporter | ||
Comment 1•22 years ago
|
||
Reporter | ||
Comment 2•22 years ago
|
||
I cimmitted the fix
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•