I take it
Assignee: rogerl → joshua.xia
OS: Windows 2000 → All
Created attachment 96143 [details] [diff] [review] NaN becomes zero when converted to integral value Brendan, Would you like to check this one? Thanks a lot!
can you get the \'s to all line up? (indentation appears to be 4 space *except* for the last level of indentation on java_value->j = 0; which is 3 space)
What specification states that NaN becomes 0 in a long context? If no specification states that, why would it be a reasonable thing to do? Why is raising an exception the wrong thing to do? If this is specified somewhere, don't waste your time explaining it--I'd be happy with a URL to the document stating it.
My mistake. I now see the precedent in that. Ignore my previous comment.
Comment on attachment 96143 [details] [diff] [review] NaN becomes zero when converted to integral value 1) fix the indentation to use four spaces, as timeless pointed out. 2) else after break is a non-sequitur (so was else after goto in the old code). 3) Wouldn't it be better to set member_name = (member_type) 0; and not break, falling through to the code in the macro that sets java_value->member_name = member_name? /be
Attachment #96143 - Flags: needs-work+
There's no written-in-English standard. What did 4.x do for the NaN-as-int case, Phil, can you test? /be
Yuck, 4.x was just broken. What did 6.x do? I smell an INVALID coming up for this bug. /be
Phil, what does Flanagan's latest Rhino book say in its LiveConnect data conversion section? /be
By doing some archaeology in the js/tests/lc2 directory, I found that conversion of NaN to a Java Long was deliberately commented out of the positive test mozilla/js/tests/lc2/JSToJava/long-002.js // a[i++] = new TestObject( "java.lang.Long.toString(NaN)", // java.lang.Long.toString(NaN), "0" ); and then added to the negative test we've been discussing: mozilla/js/tests/lc2/JSToJava/long-003-n.js
Also note that Java has constants to represent NaN (and other fun non-numbers) in floats and doubles (Float.NaN and Double.NaN of type |float| and |double|, respectively); no such constants exist for other numerical types.
This exception throwing rather than silent conversion of NaN to 0 is clearly a liveconnect feature, and has been for a long while in the modern, post-4.x world. 4.x is just broken. I say we mark this bug INVALID. /be
I caught a wrong bug.
Status: ASSIGNED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID
Marking Verified - Thanks to all who helped on this bug; particularly to Joshua, who uncovered the documentation error on our own site for this. I have filed bug 164308 on this: "Wrong documentation of LiveConnect JS-to-Java conversion of NaN" NOTE: the role of negative tests in our testsuite is outlined at http://www.mozilla.org/js/tests/library.html See " Testcases with filenames ending in -n". This page also contains a link explaining our new shell test driver, which is what I use: http://lxr.mozilla.org/mozilla/source/js/tests/README-jsDriver.html The output of our negative tests when run in a browser may be misleading to the user; I will have to look into that -
Status: RESOLVED → VERIFIED
Component: Java: Live Connect → Java: Live Connect
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.