public class AsynchronouslyInterruptedException extends InterruptedException implements StaticThrowable<AsynchronouslyInterruptedException>
This class is used to identify methods that should be asynchronously interruptible. Any methods that lists AsynchronouslyInterruptedException or any subclass of this class in its throws clause will be asynchronously interruptible. Within such a method, only code sequences that are enclosed by a synchronized() block are not asynchronously interruptible. However, calls to asynchronously interruptible methods that are performed within a synchronized block are, again, interruptible.
The asynchronous interrupt is generated by either a call to t.interrupt() for a RealtimeThread t or by a call to fire() for a schedulable object that currently performs code within a call to doInterruptible().
An asynchronous interrupt that is caused while the target schedulable object executes code that is not interruptible (a method that does not throw AsynchronouslyInterruptedException or a synchronized() block), the interrupt remains pending until this code enters an interruptible code section.
An AsynchronouslyInterruptedException may be caught, and it may be cleared by a call to clear(). However, propagation of an outer AsynchronouslyInterruptedException may not be stopped by a call to clear.
StaticThrowable.Hidden| Constructor and Description |
|---|
AsynchronouslyInterruptedException()
Constructor to create an instance of
AsynchronouslyInterruptedException.
|
AsynchronouslyInterruptedException(String message)
Creates an instance of
AsynchronouslyInterruptedException. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
clear()
clear checks if it is called on the AIE that is currently
pending.
|
boolean |
disable()
disable interruption by this exception.
|
boolean |
doInterruptible(Interruptible logic)
doInterruptible executes the run() method of the provided
Interruptible.
|
boolean |
enable()
enable interruption by this exception.
|
Throwable |
fillInStackTrace()
Fills in the execution stack trace.
|
boolean |
fire()
fire this exception during the execution of a doInterruptible()
section.
|
static AsynchronouslyInterruptedException |
get()
Gets the preallocated version of this
Throwable. |
Throwable |
getCause()
Returns the cause of this throwable or
null if the
cause is nonexistent or unknown. |
static AsynchronouslyInterruptedException |
getGeneric()
getGeneric returns the generic instance of
AsynchronouslyInterruptedException that is thrown on a call to
RealtimeThread.interrupt().
|
AsynchronouslyInterruptedException |
getSingleton()
For the case of legacy code that creates an RTSJ exception
explicity, this provides a means of obtaining its singleton version.
|
StackTraceElement[] |
getStackTrace()
Provides programmatic access to the stack trace information printed by
Throwable.printStackTrace(). |
Throwable |
initCause(Throwable causingThrowable)
Initializes the cause of this throwable to the specified value.
|
boolean |
isEnabled()
isEnabled returns the current state of this AIE: enabled or
disabled.
|
void |
printStackTrace()
Prints this throwable and its backtrace to the
standard error stream.
|
void |
printStackTrace(PrintStream stream)
Prints this throwable and its backtrace to the specified print stream.
|
void |
printStackTrace(PrintWriter writer)
Prints this throwable and its backtrace to the specified
print writer.
|
void |
setStackTrace(StackTraceElement[] new_stackTrace)
Sets the stack trace elements that will be returned by
Throwable.getStackTrace() and printed by Throwable.printStackTrace()
and related methods. |
static void |
throwPending()
Causes a pending
AsynchronouslyInterruptedException to be
thrown as a synchronous exception in an AI-deferred region if one
exists. |
addSuppressed, getLocalizedMessage, getMessage, getSuppressed, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetLocalizedMessage, getMessage, init, init, init, init, isStatic, writeReplacepublic AsynchronouslyInterruptedException()
public AsynchronouslyInterruptedException(String message)
AsynchronouslyInterruptedException.message - A message to identify this instance.public static AsynchronouslyInterruptedException get()
Throwable. Allocation is
done in memory that acts like ImmortalMemory. The message and
cause are cleared and the stack trace is filled out.public static AsynchronouslyInterruptedException getGeneric()
public AsynchronouslyInterruptedException getSingleton()
StaticThrowablegetSingleton in interface StaticThrowable<AsynchronouslyInterruptedException>public boolean enable()
If called from an environment that is not currently executing a doInterruptible() section for this exception, this returns false.
If an interruption with this exception occurred during the time this was disabled, a fire() will occur at the point this is re-enabled.
public boolean disable()
If called from an environment that is not currently executing a doInterruptible() section for this exception, this returns false.
If an interruption with this exception occurred during the time this was disabled, a fire() will occur at the point this is re-enabled.
public boolean isEnabled()
public boolean fire()
public boolean doInterruptible(Interruptible logic)
StaticIllegalArgumentException - iff the provided logic parameter
is null.logic - Contains the run() method that specifies the logic
to be executed in an interruptible way.public boolean clear()
throws IllegalThreadStateException
IllegalThreadStateExceptionpublic static void throwPending()
throws AsynchronouslyInterruptedException
AsynchronouslyInterruptedException to be
thrown as a synchronous exception in an AI-deferred region if one
exists.AsynchronouslyInterruptedException - when an AIE is pending.public Throwable initCause(Throwable causingThrowable)
ThrowableThis method can be called at most once. It is generally called from
within the constructor, or immediately after creating the
throwable. If this throwable was created
with Throwable(Throwable) or
Throwable(String,Throwable), this method cannot be called
even once.
An example of using this method on a legacy throwable type without other support for setting the cause is:
try {
lowLevelOp();
} catch (LowLevelException le) {
throw (HighLevelException)
new HighLevelException().initCause(le); // Legacy constructor
}
initCause in interface StaticThrowable<AsynchronouslyInterruptedException>initCause in class ThrowablecausingThrowable - the cause (which is saved for later retrieval by the
Throwable.getCause() method). (A null value is
permitted, and indicates that the cause is nonexistent or
unknown.)Throwable instance.public Throwable getCause()
Throwablenull if the
cause is nonexistent or unknown. (The cause is the throwable that
caused this throwable to get thrown.)
This implementation returns the cause that was supplied via one of
the constructors requiring a Throwable, or that was set after
creation with the Throwable.initCause(Throwable) method. While it is
typically unnecessary to override this method, a subclass can override
it to return a cause set by some other means. This is appropriate for
a "legacy chained throwable" that predates the addition of chained
exceptions to Throwable. Note that it is not
necessary to override any of the PrintStackTrace methods,
all of which invoke the getCause method to determine the
cause of a throwable.
getCause in interface StaticThrowable<AsynchronouslyInterruptedException>getCause in class Throwablenull if the
cause is nonexistent or unknown.public Throwable fillInStackTrace()
ThrowableThrowable object information about the current state of
the stack frames for the current thread.
If the stack trace of this Throwable is not
writable, calling this method has no effect.
fillInStackTrace in interface StaticThrowable<AsynchronouslyInterruptedException>fillInStackTrace in class ThrowableThrowable instance.Throwable.printStackTrace()public void setStackTrace(StackTraceElement[] new_stackTrace) throws NullPointerException
ThrowableThrowable.getStackTrace() and printed by Throwable.printStackTrace()
and related methods.
This method, which is designed for use by RPC frameworks and other
advanced systems, allows the client to override the default
stack trace that is either generated by Throwable.fillInStackTrace()
when a throwable is constructed or deserialized when a throwable is
read from a serialization stream.
If the stack trace of this Throwable is not
writable, calling this method has no effect other than
validating its argument.
setStackTrace in interface StaticThrowable<AsynchronouslyInterruptedException>setStackTrace in class ThrowableNullPointerException - if stackTrace is
null or if any of the elements of
stackTrace are nullnew_stackTrace - the stack trace elements to be associated with
this Throwable. The specified array is copied by this
call; changes in the specified array after the method invocation
returns will have no affect on this Throwable's stack
trace.public StackTraceElement[] getStackTrace()
ThrowableThrowable.printStackTrace(). Returns an array of stack trace elements,
each representing one stack frame. The zeroth element of the array
(assuming the array's length is non-zero) represents the top of the
stack, which is the last method invocation in the sequence. Typically,
this is the point at which this throwable was created and thrown.
The last element of the array (assuming the array's length is non-zero)
represents the bottom of the stack, which is the first method invocation
in the sequence.
Some virtual machines may, under some circumstances, omit one
or more stack frames from the stack trace. In the extreme case,
a virtual machine that has no stack trace information concerning
this throwable is permitted to return a zero-length array from this
method. Generally speaking, the array returned by this method will
contain one element for every frame that would be printed by
printStackTrace. Writes to the returned array do not
affect future calls to this method.
getStackTrace in interface StaticThrowable<AsynchronouslyInterruptedException>getStackTrace in class Throwablepublic void printStackTrace()
ThrowableThrowable object on the error output stream that is
the value of the field System.err. The first line of
output contains the result of the Throwable.toString() method for
this object. Remaining lines represent data previously recorded by
the method Throwable.fillInStackTrace(). The format of this
information depends on the implementation, but the following
example may be regarded as typical:
java.lang.NullPointerException
at MyClass.mash(MyClass.java:9)
at MyClass.crunch(MyClass.java:6)
at MyClass.main(MyClass.java:3)
This example was produced by running the program:
class MyClass {
public static void main(String[] args) {
crunch(null);
}
static void crunch(int[] a) {
mash(a);
}
static void mash(int[] b) {
System.out.println(b[0]);
}
}
The backtrace for a throwable with an initialized, non-null cause
should generally include the backtrace for the cause. The format
of this information depends on the implementation, but the following
example may be regarded as typical:
HighLevelException: MidLevelException: LowLevelException
at Junk.a(Junk.java:13)
at Junk.main(Junk.java:4)
Caused by: MidLevelException: LowLevelException
at Junk.c(Junk.java:23)
at Junk.b(Junk.java:17)
at Junk.a(Junk.java:11)
... 1 more
Caused by: LowLevelException
at Junk.e(Junk.java:30)
at Junk.d(Junk.java:27)
at Junk.c(Junk.java:21)
... 3 more
Note the presence of lines containing the characters "...".
These lines indicate that the remainder of the stack trace for this
exception matches the indicated number of frames from the bottom of the
stack trace of the exception that was caused by this exception (the
"enclosing" exception). This shorthand can greatly reduce the length
of the output in the common case where a wrapped exception is thrown
from same method as the "causative exception" is caught. The above
example was produced by running the program:
public class Junk {
public static void main(String args[]) {
try {
a();
} catch(HighLevelException e) {
e.printStackTrace();
}
}
static void a() throws HighLevelException {
try {
b();
} catch(MidLevelException e) {
throw new HighLevelException(e);
}
}
static void b() throws MidLevelException {
c();
}
static void c() throws MidLevelException {
try {
d();
} catch(LowLevelException e) {
throw new MidLevelException(e);
}
}
static void d() throws LowLevelException {
e();
}
static void e() throws LowLevelException {
throw new LowLevelException();
}
}
class HighLevelException extends Exception {
HighLevelException(Throwable cause) { super(cause); }
}
class MidLevelException extends Exception {
MidLevelException(Throwable cause) { super(cause); }
}
class LowLevelException extends Exception {
}
As of release 7, the platform supports the notion of
suppressed exceptions (in conjunction with the try-with-resources statement). Any exceptions that were
suppressed in order to deliver an exception are printed out
beneath the stack trace. The format of this information
depends on the implementation, but the following example may be
regarded as typical:
Exception in thread "main" java.lang.Exception: Something happened
at Foo.bar(Foo.java:10)
at Foo.main(Foo.java:5)
Suppressed: Resource$CloseFailException: Resource ID = 0
at Resource.close(Resource.java:26)
at Foo.bar(Foo.java:9)
... 1 more
Note that the "... n more" notation is used on suppressed exceptions
just at it is used on causes. Unlike causes, suppressed exceptions are
indented beyond their "containing exceptions."
An exception can have both a cause and one or more suppressed exceptions:
Exception in thread "main" java.lang.Exception: Main block
at Foo3.main(Foo3.java:7)
Suppressed: Resource$CloseFailException: Resource ID = 2
at Resource.close(Resource.java:26)
at Foo3.main(Foo3.java:5)
Suppressed: Resource$CloseFailException: Resource ID = 1
at Resource.close(Resource.java:26)
at Foo3.main(Foo3.java:5)
Caused by: java.lang.Exception: I did it
at Foo3.main(Foo3.java:8)
Likewise, a suppressed exception can have a cause:
Exception in thread "main" java.lang.Exception: Main block
at Foo4.main(Foo4.java:6)
Suppressed: Resource2$CloseFailException: Resource ID = 1
at Resource2.close(Resource2.java:20)
at Foo4.main(Foo4.java:5)
Caused by: java.lang.Exception: Rats, you caught me
at Resource2$CloseFailException.<init>(Resource2.java:45)
... 2 more
printStackTrace in interface StaticThrowable<AsynchronouslyInterruptedException>printStackTrace in class Throwablepublic void printStackTrace(PrintStream stream)
ThrowableprintStackTrace in interface StaticThrowable<AsynchronouslyInterruptedException>printStackTrace in class Throwablestream - PrintStream to use for outputpublic void printStackTrace(PrintWriter writer)
ThrowableprintStackTrace in interface StaticThrowable<AsynchronouslyInterruptedException>printStackTrace in class Throwablewriter - PrintWriter to use for outputaicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2022 aicas GmbH. All Rights Reserved.