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

exceptions in static initializer for main class not printed

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      Starting with Java 22, exceptions in static initializers for the main class are no longer printed, and instead the program will fail silently.

      REGRESSION : Last worked in version 21.0.3

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect an InternalError exception message to be printed.
      ACTUAL -
      Nothing is printed.

      ---------- BEGIN SOURCE ----------
      public class StaticInitializerExceptionBug {
         static {
            if (true)
               throw new InternalError();
         }

         public static void main(String[] args) {
         }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: