Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/lang/Error.java
38829 views
/*1* Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.lang;2627/**28* An {@code Error} is a subclass of {@code Throwable}29* that indicates serious problems that a reasonable application30* should not try to catch. Most such errors are abnormal conditions.31* The {@code ThreadDeath} error, though a "normal" condition,32* is also a subclass of {@code Error} because most applications33* should not try to catch it.34* <p>35* A method is not required to declare in its {@code throws}36* clause any subclasses of {@code Error} that might be thrown37* during the execution of the method but not caught, since these38* errors are abnormal conditions that should never occur.39*40* That is, {@code Error} and its subclasses are regarded as unchecked41* exceptions for the purposes of compile-time checking of exceptions.42*43* @author Frank Yellin44* @see java.lang.ThreadDeath45* @jls 11.2 Compile-Time Checking of Exceptions46* @since JDK1.047*/48public class Error extends Throwable {49static final long serialVersionUID = 4980196508277280342L;5051/**52* Constructs a new error with {@code null} as its detail message.53* The cause is not initialized, and may subsequently be initialized by a54* call to {@link #initCause}.55*/56public Error() {57super();58}5960/**61* Constructs a new error with the specified detail message. The62* cause is not initialized, and may subsequently be initialized by63* a call to {@link #initCause}.64*65* @param message the detail message. The detail message is saved for66* later retrieval by the {@link #getMessage()} method.67*/68public Error(String message) {69super(message);70}7172/**73* Constructs a new error with the specified detail message and74* cause. <p>Note that the detail message associated with75* {@code cause} is <i>not</i> automatically incorporated in76* this error's detail message.77*78* @param message the detail message (which is saved for later retrieval79* by the {@link #getMessage()} method).80* @param cause the cause (which is saved for later retrieval by the81* {@link #getCause()} method). (A {@code null} value is82* permitted, and indicates that the cause is nonexistent or83* unknown.)84* @since 1.485*/86public Error(String message, Throwable cause) {87super(message, cause);88}8990/**91* Constructs a new error with the specified cause and a detail92* message of {@code (cause==null ? null : cause.toString())} (which93* typically contains the class and detail message of {@code cause}).94* This constructor is useful for errors that are little more than95* wrappers for other throwables.96*97* @param cause the cause (which is saved for later retrieval by the98* {@link #getCause()} method). (A {@code null} value is99* permitted, and indicates that the cause is nonexistent or100* unknown.)101* @since 1.4102*/103public Error(Throwable cause) {104super(cause);105}106107/**108* Constructs a new error with the specified detail message,109* cause, suppression enabled or disabled, and writable stack110* trace enabled or disabled.111*112* @param message the detail message.113* @param cause the cause. (A {@code null} value is permitted,114* and indicates that the cause is nonexistent or unknown.)115* @param enableSuppression whether or not suppression is enabled116* or disabled117* @param writableStackTrace whether or not the stack trace should118* be writable119*120* @since 1.7121*/122protected Error(String message, Throwable cause,123boolean enableSuppression,124boolean writableStackTrace) {125super(message, cause, enableSuppression, writableStackTrace);126}127}128129130