Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Provide utility / enhancement to allow "===" comparison of JavaScript native objects with Java counterparts #5

Open
AFaust opened this issue Aug 26, 2013 · 1 comment
Assignees

Comments

@AFaust
Copy link
Owner

AFaust commented Aug 26, 2013

Currently, a JavaScript native String cannot be compared using "===" with a Java String even if both have identical content and are - for all intents and purposes - identical from a scripting perspective. The same applies to other types of native JavaScript value types and their Java (java.lang) counterparts.
It should be evaluated if Rhino allows us to provide an enhancement of the environment to allow transparent use of "===" for native JavaScript and equivalent Java objects.

@ghost ghost assigned AFaust Aug 26, 2013
@AFaust
Copy link
Owner Author

AFaust commented Aug 26, 2013

"===" / "!==" or better the "shallow (in)equality operator" is implemented at a static level in ScriptRuntime and can't be altered without recompiling Rhino. Only the the "==" / "!=" or regular "(in)equality operator" automatically performs a Java String-equality check if either the first left-hand-side expression resolves to a Java String or the right-hand-side expressions resolves to a Java String while the left-hand-side expression resolves to a Scriptable (NativeString is Scriptable).

Interestingly enough, the NativeString class does not seem to support "shallow (in)equality" correctly when two String literals from different source files are used as these do not evaluate to the same instance as required by the base ScriptableObject implementation for "equivalentValues()".

Furthermore, the Rhino interpretation of "===" / "!==" as "shallow (in)equality" operators does not correspond to the "strict equals" and "strict does-not-equals" operator specified in ECMA (http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.4 and http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.5)

@AFaust AFaust modified the milestone: After Summit Sep 10, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant