Closed
Bug 583766
Opened 15 years ago
Closed 15 years ago
Problem converting Java native types into JavaScript types
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: elmar.grom, Unassigned)
Details
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Build Identifier: 1.7R2
I am observing a problem while embedding Rhino into my Java application. I am creating classes in behind the scenes in Java. Some of the functions implemented there return int and long.
When JavaScript calls any of those functions and uses the return values they should be treated as normal JavaScript integer values. This seems to work for the most part -assignments work, computations work, string conversion work, if(returnValue == 15) works- However, switch/case does not manage to perform a proper match.
Listing a case using the variable with the returned value does create a match.
Reproducible: Always
Steps to Reproduce:
1.create an object in java that includes a funciton returning an integer or long value
2.call this function in the script
3.perform a switch() on the returned value
4.observe that a case using the correct return vlaue does not produce a match. Also observe that using an if() compare works fine.
case statements using the correct integer value should produce a match.
| Reporter | ||
Comment 1•15 years ago
|
||
OK, I found a work around, although to my knowledge this should not benecessary, Java native integer types should be automatically converted into a JavaScript native number.
Anyway, packing the Java long/int value into an Integer or Long and then wrapping this with the WrapFactory and calling setJavaPrimitiveWrap(false) on the WrapFactory and returning this result instead, the switch/case construct works.
Comment 2•15 years ago
|
||
If I understand this correctly, this is intended behavior when having WrapFactory.setJavaPrimitiveWrap set to true, so I'm resolving this bug as WONTFIX. Please let me know if you think there is something we should fix here.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•