JDK-8181191 : getUint32 returning Long
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u112
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2017-05-29
  • Updated: 2018-02-15
  • Resolved: 2017-06-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8
10 b12Fixed 8u152Fixed
Description
function uint32(x) {
    var buffer = new ArrayBuffer(16);
    var dataview = new DataView(buffer);
    dataview.setUint32(0, x);
    return dataview.getUint32(0);
}

print(uint32(0x7f) == uint32(0x7f));
print(uint32(0x80) == uint32(0x80));

after 8_112 returns true false
Comments
This is a regression caused by JDK-8144020.
23-06-2017

Since long is not treated as native JS number type anymore we have to use double to represent uint32.
01-06-2017

The work around is to replace the last line of the function with return dataview.getUint32(0) | 0; This forces the result to be integer (and not a wrapped Long.)
01-06-2017