Patch name: callcc.patch

Basic usage

Creating a continuation

Continuation are supported via two different ways:

(warning) In the long run most likely only one implementation will survive.

Resuming continuations

The public long resumeStack(Object context, Object stack, Object value, Throwable exception); method is used to resume a continuation. (no matter how it was created). The current stack is destroyed up to the context frame and the continuation contained in the stack object is reinstated.
The original copyStack or copyStackSimple call then returns value or throws exception.

Creating a context for continuations

Unsafe.doCopyStackContext is used to create a context stack frame for continuations. The first parameter is a Runnable whose run method will be invoked, and the second parameter is a context object (any Object) that will identify this particular doCopyStackContext invocation.

Security

The current proof-of-concept implementation will be used to explore how continuations can be used in a secure environment (applet, etc.).
Starting from a very conservative approach features will be added if they are considered secure.

Conservative approach

The first security concept will be a very conservative one:

Future considerations