# IllegalStateException

public class **IllegalStateException** extends [RuntimeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimeException.html)  

|---|---|---|
| Known Direct Subclasses [AcceptPendingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AcceptPendingException.html), [AlreadyBoundException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AlreadyBoundException.html), [AlreadyConnectedException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AlreadyConnectedException.html), [CancellationException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/CancellationException.html), [CancelledKeyException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/CancelledKeyException.html), [ClosedDirectoryStreamException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/ClosedDirectoryStreamException.html), [ClosedFileSystemException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/ClosedFileSystemException.html), [ClosedSelectorException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedSelectorException.html), [ClosedWatchServiceException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/ClosedWatchServiceException.html), [ConnectionPendingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ConnectionPendingException.html), [FormatterClosedException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/FormatterClosedException.html), [IllegalBlockingModeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/IllegalBlockingModeException.html), [InvalidMarkException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/InvalidMarkException.html), [NoConnectionPendingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NoConnectionPendingException.html), [NonReadableChannelException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NonReadableChannelException.html), and [7 others.](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException#) |---|---| | [AcceptPendingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AcceptPendingException.html) | Unchecked exception thrown when an attempt is made to initiate an accept operation on a channel and a previous accept operation has not completed. | | [AlreadyBoundException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AlreadyBoundException.html) | Unchecked exception thrown when an attempt is made to bind the socket a network oriented channel that is already bound. | | [AlreadyConnectedException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AlreadyConnectedException.html) | Unchecked exception thrown when an attempt is made to connect a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html` that is already connected. | | [CancellationException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/CancellationException.html) | Exception indicating that the result of a value-producing task, such as a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/FutureTask.html`, cannot be retrieved because the task was cancelled. | | [CancelledKeyException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/CancelledKeyException.html) | Unchecked exception thrown when an attempt is made to use a selection key that is no longer valid. | | [ClosedDirectoryStreamException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/ClosedDirectoryStreamException.html) | Unchecked exception thrown when an attempt is made to invoke an operation on a directory stream that is closed. | | [ClosedFileSystemException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/ClosedFileSystemException.html) | Unchecked exception thrown when an attempt is made to invoke an operation on a file and the file system is closed. | | [ClosedSelectorException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ClosedSelectorException.html) | Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a closed selector. | | [ClosedWatchServiceException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/ClosedWatchServiceException.html) | Unchecked exception thrown when an attempt is made to invoke an operation on a watch service that is closed. | | [ConnectionPendingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ConnectionPendingException.html) | Unchecked exception thrown when an attempt is made to connect a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html` for which a non-blocking connection operation is already in progress. | | [FormatterClosedException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/FormatterClosedException.html) | Unchecked exception thrown when the formatter has been closed. | | [IllegalBlockingModeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/IllegalBlockingModeException.html) | Unchecked exception thrown when a blocking-mode-specific operation is invoked upon a channel in the incorrect blocking mode. | | [InvalidMarkException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/InvalidMarkException.html) | Unchecked exception thrown when an attempt is made to reset a buffer when its mark is not defined. | | [NoConnectionPendingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NoConnectionPendingException.html) | Unchecked exception thrown when the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html#finishConnect()` method of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html` is invoked without first successfully invoking its `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html#connect(java.net.SocketAddress)` method. | | [NonReadableChannelException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NonReadableChannelException.html) | Unchecked exception thrown when an attempt is made to read from a channel that was not originally opened for reading. | | [NonWritableChannelException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NonWritableChannelException.html) | Unchecked exception thrown when an attempt is made to write to a channel that was not originally opened for writing. | | [NotYetBoundException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NotYetBoundException.html) | Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a server socket channel that is not yet bound. | | [NotYetConnectedException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NotYetConnectedException.html) | Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a socket channel that is not yet connected. | | [OverlappingFileLockException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/OverlappingFileLockException.html) | Unchecked exception thrown when an attempt is made to acquire a lock on a region of a file that overlaps a region already locked by the same Java virtual machine, or when another thread is already waiting to lock an overlapping region of the same file. | | [ReadPendingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ReadPendingException.html) | Unchecked exception thrown when an attempt is made to read from an asynchronous socket channel and a previous read has not completed. | | [ShutdownChannelGroupException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ShutdownChannelGroupException.html) | Unchecked exception thrown when an attempt is made to construct a channel in a group that is shutdown or the completion handler for an I/O operation cannot be invoked because the channel group has terminated. | | [WritePendingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/WritePendingException.html) | Unchecked exception thrown when an attempt is made to write to an asynchronous socket channel and a previous write has not completed. | |||

Signals that a method has been invoked at an illegal or
inappropriate time. In other words, the Java environment or
Java application is not in an appropriate state for the requested
operation.

### Public Constructor Summary

|---|---|
|   | [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html#IllegalStateException())() Constructs an IllegalStateException with no detail message. |
|   | [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html#IllegalStateException(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) s) Constructs an IllegalStateException with the specified detail message. |
|   | [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html#IllegalStateException(java.lang.String,%20java.lang.Throwable))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) message, [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) cause) Constructs a new exception with the specified detail message and cause. |
|   | [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html#IllegalStateException(java.lang.Throwable))([Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) cause) Constructs a new exception with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). |

### Inherited Method Summary

From class [java.lang.Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html)

|---|---|
| synchronized final void | [addSuppressed](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#addSuppressed(java.lang.Throwable))([Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) exception) Appends the specified exception to the exceptions that were suppressed in order to deliver this exception. |
| synchronized [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) | [fillInStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#fillInStackTrace())() Fills in the execution stack trace. |
| synchronized [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) | [getCause](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getCause())() Returns the cause of this throwable or `null` if the cause is nonexistent or unknown. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getLocalizedMessage](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getLocalizedMessage())() Creates a localized description of this throwable. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getMessage](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getMessage())() Returns the detail message string of this throwable. |
| StackTraceElement\[\] | [getStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getStackTrace())() Provides programmatic access to the stack trace information printed by `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace()`. |
| synchronized final [Throwable\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) | [getSuppressed](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getSuppressed())() Returns an array containing all of the exceptions that were suppressed, typically by the `try`-with-resources statement, in order to deliver this exception. |
| synchronized [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) | [initCause](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#initCause(java.lang.Throwable))([Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) cause) Initializes the *cause* of this throwable to the specified value. |
| void | [printStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace())() Prints this throwable and its backtrace to the standard error stream. |
| void | [printStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace(java.io.PrintWriter))([PrintWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintWriter.html) s) Prints this throwable and its backtrace to the specified print writer. |
| void | [printStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace(java.io.PrintStream))([PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) s) Prints this throwable and its backtrace to the specified print stream. |
| void | [setStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#setStackTrace(java.lang.StackTraceElement[]))(StackTraceElement\[\] stackTrace) Sets the stack trace elements that will be returned by `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getStackTrace()` and printed by `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace()` and related methods. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#toString())() Returns a short description of this throwable. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Public Constructors

#### public
**IllegalStateException**
()

Constructs an IllegalStateException with no detail message.
A detail message is a String that describes this particular exception.

#### public
**IllegalStateException**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) s)

Constructs an IllegalStateException with the specified detail
message. A detail message is a String that describes this particular
exception.

##### Parameters

| s | the String that contains a detailed message |
|---|---|

#### public
**IllegalStateException**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) message, [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) cause)

Constructs a new exception with the specified detail message and
cause.

Note that the detail message associated with `cause` is
*not* automatically incorporated in this exception's detail
message.

##### Parameters

| message | the detail message (which is saved for later retrieval by the `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getMessage()` method). |
| cause | the cause (which is saved for later retrieval by the `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getCause()` method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.) |
|---|---|

#### public
**IllegalStateException**
([Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) cause)

Constructs a new exception with the specified cause and a detail
message of (cause==null ? null : cause.toString()) (which
typically contains the class and detail message of cause).
This constructor is useful for exceptions that are little more than
wrappers for other throwables (for example, `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedActionException.html`).

##### Parameters

| cause | the cause (which is saved for later retrieval by the `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getCause()` method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.) |
|---|---|