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

Coercion of Enums in Nashorn yields different result in Nashorn than in Rhino

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u31
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.8.0_31"
      Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux krausem 3.13.0-44-generic #73~precise1-Ubuntu SMP Wed Dec 17 00:39:15 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      It seems that Java enums are no longer coerced into their string value:

      java.math.RoundingMode.UP == "UP"

      evaluates to true in Java 7 but to false in Java 8.

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.7.0_65"
      Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      krausem-> /opt/jdk1.7.0_65/bin/jrunscript -e 'print(java.math.RoundingMode.UP == "UP")'
      true
      [~]
      krausem-> /big/jdk1.8.0_40/bin/jrunscript -e 'print(java.math.RoundingMode.UP == "UP")'
      false


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      true in both cases
      ACTUAL -
      false in JDK 1.8

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      krausem-> /opt/jdk1.7.0_65/bin/jrunscript -e 'print(java.math.RoundingMode.UP == "UP")'
      true
      [~]
      krausem-> /big/jdk1.8.0_40/bin/jrunscript -e 'print(java.math.RoundingMode.UP == "UP")'
      false
      ---------- END SOURCE ----------

            hannesw Hannes Wallnoefer
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: