1 /*
2  * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package java.lang;
27 
28 /**
29  * Signals that a method has been invoked at an illegal or
30  * inappropriate time.  In other words, the Java environment or
31  * Java application is not in an appropriate state for the requested
32  * operation.
33  *
34  * @author  Jonni Kanerva
35  * @since   1.1
36  */
37 public class IllegalStateException extends RuntimeException {
38     /**
39      * Constructs an IllegalStateException with no detail message.
40      * A detail message is a String that describes this particular exception.
41      */
IllegalStateException()42     public IllegalStateException() {
43         super();
44     }
45 
46     /**
47      * Constructs an IllegalStateException with the specified detail
48      * message.  A detail message is a String that describes this particular
49      * exception.
50      *
51      * @param s the String that contains a detailed message
52      */
IllegalStateException(String s)53     public IllegalStateException(String s) {
54         super(s);
55     }
56 
57     /**
58      * Constructs a new exception with the specified detail message and
59      * cause.
60      *
61      * <p>Note that the detail message associated with {@code cause} is
62      * <i>not</i> automatically incorporated in this exception's detail
63      * message.
64      *
65      * @param  message the detail message (which is saved for later retrieval
66      *         by the {@link Throwable#getMessage()} method).
67      * @param  cause the cause (which is saved for later retrieval by the
68      *         {@link Throwable#getCause()} method).  (A {@code null} value
69      *         is permitted, and indicates that the cause is nonexistent or
70      *         unknown.)
71      * @since 1.5
72      */
IllegalStateException(String message, Throwable cause)73     public IllegalStateException(String message, Throwable cause) {
74         super(message, cause);
75     }
76 
77     /**
78      * Constructs a new exception with the specified cause and a detail
79      * message of {@code (cause==null ? null : cause.toString())} (which
80      * typically contains the class and detail message of {@code cause}).
81      * This constructor is useful for exceptions that are little more than
82      * wrappers for other throwables (for example, {@link
83      * java.security.PrivilegedActionException}).
84      *
85      * @param  cause the cause (which is saved for later retrieval by the
86      *         {@link Throwable#getCause()} method).  (A {@code null} value is
87      *         permitted, and indicates that the cause is nonexistent or
88      *         unknown.)
89      * @since  1.5
90      */
IllegalStateException(Throwable cause)91     public IllegalStateException(Throwable cause) {
92         super(cause);
93     }
94 
95     @java.io.Serial
96     static final long serialVersionUID = -1848914673093119416L;
97 }
98