< prev index next >

src/java.base/share/classes/java/lang/Error.java

Print this page




  30  * that indicates serious problems that a reasonable application
  31  * should not try to catch. Most such errors are abnormal conditions.
  32  * The {@code ThreadDeath} error, though a "normal" condition,
  33  * is also a subclass of {@code Error} because most applications
  34  * should not try to catch it.
  35  * <p>
  36  * A method is not required to declare in its {@code throws}
  37  * clause any subclasses of {@code Error} that might be thrown
  38  * during the execution of the method but not caught, since these
  39  * errors are abnormal conditions that should never occur.
  40  *
  41  * That is, {@code Error} and its subclasses are regarded as unchecked
  42  * exceptions for the purposes of compile-time checking of exceptions.
  43  *
  44  * @author  Frank Yellin
  45  * @see     java.lang.ThreadDeath
  46  * @jls 11.2 Compile-Time Checking of Exceptions
  47  * @since   1.0
  48  */
  49 public class Error extends Throwable {

  50     static final long serialVersionUID = 4980196508277280342L;
  51 
  52     /**
  53      * Constructs a new error with {@code null} as its detail message.
  54      * The cause is not initialized, and may subsequently be initialized by a
  55      * call to {@link #initCause}.
  56      */
  57     public Error() {
  58         super();
  59     }
  60 
  61     /**
  62      * Constructs a new error with the specified detail message.  The
  63      * cause is not initialized, and may subsequently be initialized by
  64      * a call to {@link #initCause}.
  65      *
  66      * @param   message   the detail message. The detail message is saved for
  67      *          later retrieval by the {@link #getMessage()} method.
  68      */
  69     public Error(String message) {




  30  * that indicates serious problems that a reasonable application
  31  * should not try to catch. Most such errors are abnormal conditions.
  32  * The {@code ThreadDeath} error, though a "normal" condition,
  33  * is also a subclass of {@code Error} because most applications
  34  * should not try to catch it.
  35  * <p>
  36  * A method is not required to declare in its {@code throws}
  37  * clause any subclasses of {@code Error} that might be thrown
  38  * during the execution of the method but not caught, since these
  39  * errors are abnormal conditions that should never occur.
  40  *
  41  * That is, {@code Error} and its subclasses are regarded as unchecked
  42  * exceptions for the purposes of compile-time checking of exceptions.
  43  *
  44  * @author  Frank Yellin
  45  * @see     java.lang.ThreadDeath
  46  * @jls 11.2 Compile-Time Checking of Exceptions
  47  * @since   1.0
  48  */
  49 public class Error extends Throwable {
  50     @java.io.Serial
  51     static final long serialVersionUID = 4980196508277280342L;
  52 
  53     /**
  54      * Constructs a new error with {@code null} as its detail message.
  55      * The cause is not initialized, and may subsequently be initialized by a
  56      * call to {@link #initCause}.
  57      */
  58     public Error() {
  59         super();
  60     }
  61 
  62     /**
  63      * Constructs a new error with the specified detail message.  The
  64      * cause is not initialized, and may subsequently be initialized by
  65      * a call to {@link #initCause}.
  66      *
  67      * @param   message   the detail message. The detail message is saved for
  68      *          later retrieval by the {@link #getMessage()} method.
  69      */
  70     public Error(String message) {


< prev index next >