ATCT for Scripting Engines
The simplicity and wide cross-platform availability of the JVM have spawned many alternative languages
that target it as their run-time environment. Some languages are native compilers that directly generate bytecode, while the others are run-time interpreters. Two types of interpreters exist: the ones that implement their own internal execution stack and those that rely on the JVM's internal stack. However, all these languages share a common limitation inherent to the JVM itself: no way to control the execution stack of the Java bytecode interpreter. Consequently, the interpreters that rely on the JVM cannot offer continuation: the ability to suspend/resume a method's execution at will. Continuation is a fundamental requirement for scripting a series of asynchronous events.
The programmers of the Apache Cocoon framework are keenly aware of this limitation and discussed it at length. Their powerful Web development framework allows the creation of Web sites using XML documents. It also includes the interesting ability to control the flow between a series of Web pages using a simple script interpreted at run time. This functionality relies on the scripting engine's ability to support continuation. The JVM's lack of support for this feature drastically limits the choice of scripting languages that developers can use with Cocoon or in any other similar situation.
To be able to suspend/resume the execution of bytecode would require storing the following state information about the JVM:
Program state: bytecode of the object's class
Data state: the content of the instance variable inside the
Execution state: the content of the VM's pc register, allowing it to sequentially execute the code at the proper location; plus the content of the stack associated with the Thread executing the bytecode. The stack is made of a series of frames. Each frame holds the content of the local variables declared in each of the methods for which the VM has not reached an exit point yet.
Currently, Sun offers no direct way to access the execution state. ATCT is the first portable technology to offer unrestricted Java continuation. Curious about how Velare solved this problem? The next section breaks it down.