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

ExceptionInInitializerError.initCause() always throws exception

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      It is not possible to create a java.lang.ExceptionInInitializerError with both message and cause, the reasons for this are:
      - Such a constructor is missing
      - The constructor ExceptionInInitializerError(String) prevents usage of `initCause(...)`

      Therefore it would be good to add a constructor `ExceptionInInitializerError(String message, Throwable cause)`.

      Note that the documentation for `ExceptionInInitializerError` should be improved (and `initCause(...)` should be overridden to add documentation and mark it as @Deprecated?) to indicate that calling `initCause(...)` is never possible, regardless of which constructor is used.


      ---------- BEGIN SOURCE ----------
      Exception cause = new Exception("Cause");
      new ExceptionInInitializerError("Custom message").initCause(cause);
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated: