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

No error message when ExceptionInInitializerError thrown in static initializer

    XMLWordPrintable

Details

    • b27
    • 22
    • b26
    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Debian Bookworm
      openjdk 22 2024-03-19
      OpenJDK Runtime Environment (build 22+36-2370)
      OpenJDK 64-Bit Server VM (build 22+36-2370, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      When an error is thrown in the static initializer I except to see an error message like I did in JDK 21, but the program silently terminates.

      REGRESSION : Last worked in version 21.0.3

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile & run the example class with JDK 22

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I see an error message about an unhandled exception with my error message
      ACTUAL -
      The program terminates without writing anything to stdout

      ---------- BEGIN SOURCE ----------
      public class Example {

        static {
          if (true) {
            throw new ExceptionInInitializerError("I should see this error");
          }
        }

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

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

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              szaldana Sonia Zaldana Calles
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: