JDK-8330864 : No error message when ExceptionInInitializerError thrown in static initializer
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 22,23
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-04-22
  • Updated: 2024-06-07
  • Resolved: 2024-06-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b26Fixed
Related Reports
Duplicate :  
Relates :  
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



Comments
Changeset: cbb6747e Author: Sonia Zaldana Calles <szaldana@openjdk.org> Committer: Jaikiran Pai <jpai@openjdk.org> Date: 2024-06-05 13:12:30 +0000 URL: https://git.openjdk.org/jdk/commit/cbb6747e6b9ce7e2b9e0ffb0a1f9499f7e0e13b0
05-06-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18786 Date: 2024-04-15 18:25:02 +0000
31-05-2024

Sonia, can you verify that this issue is fixed once you fix JDK-8329581 ? Thanks.
30-04-2024

This appears to be a duplicate of https://bugs.openjdk.org/browse/JDK-8329581, for which, as Alan notes, a PR is currently under review https://github.com/openjdk/jdk/pull/18786
26-04-2024

There are changes in progress for JDK 23 to fix java launcher exception handling.
23-04-2024

The observation on Windows 11: JDK 22+26: Passed. JDK 22+27: Failed, no ExceptionInInitializerError: I should see this error JDK 23ea+14: Failed.
23-04-2024