Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8144131

ArrayData.getInt implementations do not convert to int32

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b96
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        The getInt(int) implementations in NumberArrayData and LongArrayData just casts the element value to int, which is not correct JS semantics. What we should do is call JSType.toInt32. This can be seen by running the following script:

        x = [0xffffffff, 0.5] // second element makes this a double array
        print(x[0] & -10)
        y = 0xffffffff
        print(y & -10)

        Expected output:

        -10
        -10

        Actual output:

        2147483638
        -10

          Activity

          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/d81b4da915da
          User: hannesw
          Date: 2015-12-01 08:54:23 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/d81b4da915da User: hannesw Date: 2015-12-01 08:54:23 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/nashorn/rev/d81b4da915da
          User: lana
          Date: 2015-12-10 00:26:41 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/nashorn/rev/d81b4da915da User: lana Date: 2015-12-10 00:26:41 +0000

            People

            • Assignee:
              hannesw Hannes Wallnoefer
              Reporter:
              hannesw Hannes Wallnoefer
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: