C2: ClassCastException misses exception message

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      - openjdk version "25.0.3-internal" 2026-04-21 (I couldn't find it in the dropdown menu)
      - Operating system: Linux
      - Compiler/toolchain: GCC 9.4
      - Source commit: 748bc9b1d3029fdaa66a2ba7bf8d02edc35edf3e
      - Build type: fastdebug

      A DESCRIPTION OF THE PROBLEM :
      Running the following program in -Xcomp will output an error message:
      ```
      Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.contains(java.lang.CharSequence)" because the return value of "java.lang.ClassCastException.getMessage()" is null
              at CCEMessageTest.main(CCEMessageTest.java:22)
      ```
      Run the following program in -Xint and the result is normal


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javac CCEMessageTest.java

      java -Xcomp CCEMessageTest

      ---------- BEGIN SOURCE ----------
      public class CCEMessageTest {

          public static void main(java.lang.String... args) {
              long[] lv_long_arr_1769819347395_81002850302450750 = new long[AllFuzzerDefs_1769819346167_25363.ARRAY_SIZE];
              String lv_String_1769819347395_81002850310746260 = new String("");
              float lv_float_1769819347395_81002850306271571 = 375.6383f;
              float lv_float_1769819347395_81002850306175780 = 375.6383f;
              int lv_int_1769819347395_81002850305514911 = 188;
              int lv_int_1769819347387_81002850224013410 = 188;
              long lv_long_1769819347395_81002850303938773 = 15850L;
              long lv_long_1769819347395_81002850307850234 = 15850L;
              long lv_long_1769819347393_81002850282619531 = 15850L;
              for (int TmpVar_8100285045050253_1769819347409 = 0; TmpVar_8100285045050253_1769819347409 < lv_long_arr_1769819347395_81002850302450750.length; TmpVar_8100285045050253_1769819347409++) {
                  lv_long_arr_1769819347395_81002850302450750[TmpVar_8100285045050253_1769819347409] = (((long) (TmpVar_8100285045050253_1769819347409)) * 100) + 12L;
              }
              java.lang.String[] s = null;
              for (lv_int_1769819347387_81002850224013410 = 0; lv_int_1769819347387_81002850224013410 < 333; lv_int_1769819347387_81002850224013410++) {
                  try {
                      s = ((java.lang.String[]) (new java.lang.Object[1]));
                  } catch (java.lang.ClassCastException cce) {
                      System.out.println("Caught expected ClassCastException");
                      if (!cce.getMessage().contains("[Ljava.lang.String;")) {
                          throw new java.lang.AssertionError("Incorrect CCE message", cce);
                      }
                  }
                  if (s != null) {
                      throw new java.lang.AssertionError("Unexpected error");
                  }
                  
                  for (lv_int_1769819347395_81002850305514911 = 0; lv_int_1769819347395_81002850305514911 < 333; lv_int_1769819347395_81002850305514911++) {
                      
                      for (lv_int_1769819347395_81002850305514911 = 0; lv_int_1769819347395_81002850305514911 < 333; lv_int_1769819347395_81002850305514911++) {

                          AllFuzzerDefs_1769819346167_25363.gb_long_1769819347394_81002850299375141 = (((lv_long_1769819347393_81002850282619531 >>> (Integer.MIN_VALUE % 64)) | (lv_long_1769819347393_81002850282619531 << (64 - (Integer.MIN_VALUE % 64)))) ^ (26764L)) + (Math.min(lv_long_1769819347395_81002850307850234 - lv_long_1769819347395_81002850303938773, 0));
                          
                          lv_String_1769819347395_81002850310746260 = AllFuzzerDefs_1769819346167_25363.gb_String_1769819347395_81002850310892180;
                      }
                      
                      AllFuzzerDefs_1769819346167_25363.gb_long_1769819347393_81002850282869360 = ((lv_long_1769819347395_81002850307850234 << (863 % 64)) | (lv_long_1769819347395_81002850307850234 >>> (64 - (863 % 64)))) + ((AllFuzzerDefs_1769819346167_25363.gb_int_1769819347397_81002850321932000) / Long.MIN_VALUE);
                      
                      lv_float_1769819347395_81002850306175780 = lv_float_1769819347395_81002850306271571;
                      lv_float_1769819347395_81002850306175780 = 341.41452f;
                  
                  }
              
              
              }
              
              
          }
      }

      class AllFuzzerDefs_1769819346167_25363 {

          public static int ARRAY_SIZE = 80;

          public static String gb_String_1769819347395_81002850310892180 = new String("");

          public static long gb_long_1769819347394_81002850299375141 = 15850L;

          public static long gb_long_1769819347395_81002850302297732 = 15850L;

          public static long gb_long_1769819347393_81002850282869360 = 15850L;

          public static long gb_long_1769819347397_81002850329129033 = 15850L;

          public static int gb_int_1769819347397_81002850321932000 = 188;

      }


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

      FREQUENCY :
      ALWAYS

            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: