RuntimeException.java revision 4116
869N/A/*
869N/A * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
869N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
869N/A *
869N/A * This code is free software; you can redistribute it and/or modify it
869N/A * under the terms of the GNU General Public License version 2 only, as
869N/A * published by the Free Software Foundation. Oracle designates this
869N/A * particular file as subject to the "Classpath" exception as provided
869N/A * by Oracle in the LICENSE file that accompanied this code.
869N/A *
869N/A * This code is distributed in the hope that it will be useful, but WITHOUT
869N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
869N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
869N/A * version 2 for more details (a copy is included in the LICENSE file that
869N/A * accompanied this code).
869N/A *
869N/A * You should have received a copy of the GNU General Public License version
873N/A * 2 along with this work; if not, write to the Free Software Foundation,
869N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
869N/A *
869N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
869N/A * or visit www.oracle.com if you need additional information or have any
5005N/A * questions.
6045N/A */
5934N/A
869N/Apackage java.lang;
869N/A
0N/A/**
0N/A * {@code RuntimeException} is the superclass of those
0N/A * exceptions that can be thrown during the normal operation of the
0N/A * Java Virtual Machine.
869N/A *
0N/A * <p>{@code RuntimeException} and its subclasses are <em>unchecked
0N/A * exceptions</em>. Unchecked exceptions do <em>not</em> need to be
0N/A * declared in a method or constructor's {@code throws} clause if they
869N/A * can be thrown by the execution of the method or constructor and
0N/A * propagate outside the method or constructor boundary.
869N/A *
0N/A * @author Frank Yellin
869N/A * @jls 11.2 Compile-Time Checking of Exceptions
869N/A * @since JDK1.0
869N/A */
2624N/Apublic class RuntimeException extends Exception {
869N/A static final long serialVersionUID = -7034897190745766939L;
48N/A
869N/A /** Constructs a new runtime exception with {@code null} as its
0N/A * detail message. The cause is not initialized, and may subsequently be
869N/A * initialized by a call to {@link #initCause}.
716N/A */
869N/A public RuntimeException() {
1958N/A super();
1963N/A }
2340N/A
3103N/A /** Constructs a new runtime exception with the specified detail message.
3127N/A * The cause is not initialized, and may subsequently be initialized by a
3679N/A * call to {@link #initCause}.
5244N/A *
1954N/A * @param message the detail message. The detail message is saved for
1954N/A * later retrieval by the {@link #getMessage()} method.
1954N/A */
1954N/A public RuntimeException(String message) {
1954N/A super(message);
1954N/A }
4306N/A
4306N/A /**
4306N/A * Constructs a new runtime exception with the specified detail message and
1954N/A * cause. <p>Note that the detail message associated with
1954N/A * {@code cause} is <i>not</i> automatically incorporated in
1954N/A * this runtime exception's detail message.
1954N/A *
5221N/A * @param message the detail message (which is saved for later retrieval
0N/A * by the {@link #getMessage()} method).
0N/A * @param cause the cause (which is saved for later retrieval by the
869N/A * {@link #getCause()} method). (A <tt>null</tt> value is
868N/A * permitted, and indicates that the cause is nonexistent or
2624N/A * unknown.)
2693N/A * @since 1.4
2042N/A */
4563N/A public RuntimeException(String message, Throwable cause) {
5408N/A super(message, cause);
4898N/A }
4898N/A
2980N/A /** Constructs a new runtime exception with the specified cause and a
2963N/A * detail message of <tt>(cause==null ? null : cause.toString())</tt>
1503N/A * (which typically contains the class and detail message of
2915N/A * <tt>cause</tt>). This constructor is useful for runtime exceptions
869N/A * that are little more than wrappers for other throwables.
2624N/A *
2624N/A * @param cause the cause (which is saved for later retrieval by the
0N/A * {@link #getCause()} method). (A <tt>null</tt> value is
2270N/A * permitted, and indicates that the cause is nonexistent or
2270N/A * unknown.)
2270N/A * @since 1.4
2270N/A */
2270N/A public RuntimeException(Throwable cause) {
2270N/A super(cause);
2270N/A }
0N/A
869N/A /**
868N/A * Constructs a new runtime exception with the specified detail
0N/A * message, cause, suppression enabled or disabled, and writable
0N/A * stack trace enabled or disabled.
65N/A *
869N/A * @param message the detail message.
868N/A * @param cause the cause. (A {@code null} value is permitted,
65N/A * and indicates that the cause is nonexistent or unknown.)
869N/A * @param enableSuppression whether or not suppression is enabled
2624N/A * or disabled
2624N/A * @param writableStackTrace whether or not the stack trace should
65N/A * be writable
65N/A *
65N/A * @since 1.7
65N/A */
65N/A protected RuntimeException(String message, Throwable cause,
65N/A boolean enableSuppression,
65N/A boolean writableStackTrace) {
65N/A super(message, cause, enableSuppression, writableStackTrace);
65N/A }
65N/A}
65N/A