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

-XX:+ShowCodeDetailsInExceptionMessages not working properly for String concat

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10

      A DESCRIPTION OF THE PROBLEM :
      I tried concat two string with null. -XX:+ShowCodeDetailsInExceptionMessages has to show the exact variable name which is null. Instead it shows "str" is null.

      Please look into it.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute this program:

      package jdk14.newfeatures.nullpointerexcptn;

      public class NullPointerExcptn {

      //static Object obj = null;

      public static void main(String[] args) {

      //obj.hashCode();
      String firstname = "Andrea";
      String lastname = null;

      System.out.println(firstname.concat(lastname));

      }

      }




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because "lastname" is null
      at java.base/java.lang.String.concat(String.java:1965)
      at jdk14.newfeatures.nullpointerexcptn.NullPointerExcptn.main(NullPointerExcptn.java:13)

      ACTUAL -
      Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because "str" is null
      at java.base/java.lang.String.concat(String.java:1965)
      at jdk14.newfeatures.nullpointerexcptn.NullPointerExcptn.main(NullPointerExcptn.java:13)


      ---------- BEGIN SOURCE ----------
      package jdk14.newfeatures.nullpointerexcptn;

      public class NullPointerExcptn {

      //static Object obj = null;

      public static void main(String[] args) {

      //obj.hashCode();
      String firstname = "Andrea";
      String lastname = null;

      System.out.println(firstname.concat(lastname));

      }

      }

      ---------- END SOURCE ----------

            forax Rémi Forax
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: