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

java.lang.Long is implicitly converted to double

    Details

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

      Backports

        Description

        This bug was reported by Tomas Hurka via mail.

        On JDK 8, calling Long.valueOf("301077366599181567") and converting the result to string seems to convert the number to double since the result shows a loss of precision.

        nashorn> java.lang.Long.valueOf("301077366599181567").toString()
        301077366599181570

        If toString() would have been called on the java.lang.Long instance, the result should not loose precision and be the same as the input string.

          Issue Links

            Activity

            Hide
            hannesw Hannes Wallnoefer added a comment -
            The problem is that the lookup of "toString" on the java.lang.Long instance is handled by the NashornPrimitiveLinker (which is a prioritized linker), not the BeansLinker. Therefore, we end up calling Number.prototype.toString() instead of java.lang.Long.toString().
            Show
            hannesw Hannes Wallnoefer added a comment - The problem is that the lookup of "toString" on the java.lang.Long instance is handled by the NashornPrimitiveLinker (which is a prioritized linker), not the BeansLinker. Therefore, we end up calling Number.prototype.toString() instead of java.lang.Long.toString().
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/8faab9cd4b95
            User: hannesw
            Date: 2016-01-12 15:30:24 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/8faab9cd4b95 User: hannesw Date: 2016-01-12 15:30:24 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/nashorn/rev/8faab9cd4b95
            User: lana
            Date: 2016-01-20 20:50:58 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/nashorn/rev/8faab9cd4b95 User: lana Date: 2016-01-20 20:50:58 +0000

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: