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

assign Long to variable cast it to Integer

    XMLWordPrintable

Details

    • b01
    • 11
    • generic
    • generic

    Description

      A DESCRIPTION OF THE PROBLEM :
      reproduce bug code:
      import javax.script.ScriptEngine;
      import javax.script.ScriptEngineManager;
      import javax.script.ScriptException;

      public class Main {
          public static void main(String[] args) {
              ScriptEngineManager factory = new ScriptEngineManager();
              ScriptEngine engine = factory.getEngineByName("nashorn");
              try {
                  String script = "var Long = Java.type('java.lang.Long');" +
                          "var id = Long.valueOf('1');" +
                          "print(Long.valueOf('1').equals(id));" +
                          "print(Long.valueOf('1').getClass());" +
                          "print(id.getClass());";
                  engine.eval(script);
              } catch (ScriptException se) {
                  se.printStackTrace();
              }
          }
      }

      JDK 11 Output:
      false
      class java.lang.Long
      class java.lang.Integer

      JDK 8 Output:
      true
      class java.lang.Long
      class java.lang.Long

      REGRESSION : Last worked in version 8u361


      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              wxiao Weibing Xiao
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: