Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/lang/Exception.java
38829 views
/*1* Copyright (c) 1994, 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* The class {@code Exception} and its subclasses are a form of29* {@code Throwable} that indicates conditions that a reasonable30* application might want to catch.31*32* <p>The class {@code Exception} and any subclasses that are not also33* subclasses of {@link RuntimeException} are <em>checked34* exceptions</em>. Checked exceptions need to be declared in a35* method or constructor's {@code throws} clause if they can be thrown36* by the execution of the method or constructor and propagate outside37* the method or constructor boundary.38*39* @author Frank Yellin40* @see java.lang.Error41* @jls 11.2 Compile-Time Checking of Exceptions42* @since JDK1.043*/44public class Exception extends Throwable {45static final long serialVersionUID = -3387516993124229948L;4647/**48* Constructs a new exception with {@code null} as its detail message.49* The cause is not initialized, and may subsequently be initialized by a50* call to {@link #initCause}.51*/52public Exception() {53super();54}5556/**57* Constructs a new exception with the specified detail message. The58* cause is not initialized, and may subsequently be initialized by59* a call to {@link #initCause}.60*61* @param message the detail message. The detail message is saved for62* later retrieval by the {@link #getMessage()} method.63*/64public Exception(String message) {65super(message);66}6768/**69* Constructs a new exception with the specified detail message and70* cause. <p>Note that the detail message associated with71* {@code cause} is <i>not</i> automatically incorporated in72* this exception's detail message.73*74* @param message the detail message (which is saved for later retrieval75* by the {@link #getMessage()} method).76* @param cause the cause (which is saved for later retrieval by the77* {@link #getCause()} method). (A <tt>null</tt> value is78* permitted, and indicates that the cause is nonexistent or79* unknown.)80* @since 1.481*/82public Exception(String message, Throwable cause) {83super(message, cause);84}8586/**87* Constructs a new exception with the specified cause and a detail88* message of <tt>(cause==null ? null : cause.toString())</tt> (which89* typically contains the class and detail message of <tt>cause</tt>).90* This constructor is useful for exceptions that are little more than91* wrappers for other throwables (for example, {@link92* java.security.PrivilegedActionException}).93*94* @param cause the cause (which is saved for later retrieval by the95* {@link #getCause()} method). (A <tt>null</tt> value is96* permitted, and indicates that the cause is nonexistent or97* unknown.)98* @since 1.499*/100public Exception(Throwable cause) {101super(cause);102}103104/**105* Constructs a new exception with the specified detail message,106* cause, suppression enabled or disabled, and writable stack107* trace enabled or disabled.108*109* @param message the detail message.110* @param cause the cause. (A {@code null} value is permitted,111* and indicates that the cause is nonexistent or unknown.)112* @param enableSuppression whether or not suppression is enabled113* or disabled114* @param writableStackTrace whether or not the stack trace should115* be writable116* @since 1.7117*/118protected Exception(String message, Throwable cause,119boolean enableSuppression,120boolean writableStackTrace) {121super(message, cause, enableSuppression, writableStackTrace);122}123}124125126