|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jauvm.Continuation
public class Continuation
A continuation representing the stored execution state of an Interpreter
object.
Continuation
object wraps a given method invocation, which can later (and even repeatedly) be returned from
or otherwise terminated by throwing an exception.
A Continuation
object can be created and returned to only in interpreted code, i.e. in methods tagged as
interpretable
and ran by an Interpreter
.
Interpreter
,
interpretable
Constructor Summary | |
---|---|
Continuation()
Captures the current execution state of the Interpreter as a new Continuation object. |
Method Summary | |
---|---|
static Thread |
forkThread()
Forks a new thread at the current execution point. |
static Continuation |
getCurrent()
Gets this method invocation's current continuation as a new Continuation object. |
Class<?>[] |
getExceptionTypes()
Gets the exception types declared by the method invocation wrapped in this Continuation object. |
Class<?> |
getReturnType()
Gets the return type of the method invocation wrapped in this Continuation object. |
void |
returnTo()
Returns to the execution point represented by this Continuation object (with no return value). |
void |
returnTo(Object value)
Returns value to the execution point represented by this Continuation object. |
static boolean |
saveCurrentTo(File file)
Serializes this method invocation's current continuation to the file. |
void |
throwTo(Throwable thrwbl)
Throws thrwbl to the execution point represented by this Continuation object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Continuation()
Interpreter
as a new Continuation
object.
The call to this constructor in the following example captures the execution state of the caller of aMethod()
, wrapping the current aMethod()
invocation in a Continuation
object:
public static @interpretable void aMethod() {
Continuation cont = new Continuation();
}
A continuation can only be captured in interpreted code.
UnsupportedOperationException
- if the constructor is not invoked from interpreted codeMethod Detail |
---|
public void returnTo()
Continuation
object (with no return value).
Returning to a continuation that wraps a given method invocation, is the same as returning, possibly once again,
from that method invocation.
Accordingly, this method can only be invoked on continuations of void
return type, that is, continuations
captured in a method of void
return type. Also, a continuation can only be returned to in interpreted
code.
UnsupportedOperationException
- if this method is not invoked from interpreted code
IllegalArgumentException
- if this continuation is not of void
return typegetReturnType()
public void returnTo(Object value)
value
to the execution point represented by this Continuation
object.
Returning to a continuation that wraps a given method invocation, is the same as returning, possibly once again,
from that method invocation.
Accordingly, this method can only be invoked on continuations whose return type is assignable from value
,
that is, value
must be assignable to the return type of the method the continuation was captured in. The
return value value
is assignable to that return type if there is an unwrapping and/or widening conversion
that goes from value
's type to that return type. Also, a continuation can only be returned to in
interpreted code.
value
- the value to return to this continuation
UnsupportedOperationException
- if this method is not invoked from interpreted code
IllegalArgumentException
- if value
is not assignable to this continuation's return typegetReturnType()
public void throwTo(Throwable thrwbl)
thrwbl
to the execution point represented by this Continuation
object.
Throwing an exception to a continuation that wraps a given method invocation, is the same as having that method
invocation throw the given exception.
Accordingly, thrwbl
must either be an unchecked exception, or a checked exception accepted by this
continuation, that is, a checked exception declared by method the continuation was captured in. Also, a
continuation can only be thrown to in interpreted code.
thrwbl
- the throwable to throw to this continuation
UnsupportedOperationException
- if this method is not invoked from interpreted code
IllegalArgumentException
- if thrwbl
is a checked exception not declared by this continuationgetExceptionTypes()
public Class<?> getReturnType()
Continuation
object.
public Class<?>[] getExceptionTypes()
Continuation
object.
public static Continuation getCurrent()
Continuation
object.
public static boolean saveCurrentTo(File file) throws IOException
file
- the file to which to save the continuation
Continuation
object was just saved, false if returning from the file
IOException
- if an I/O error occurs writing to the filepublic static Thread forkThread()
null
in the new thread, the new Thread
object in the current thread
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |