Browse DevX
Sign up for e-mail newsletters from DevX


Serialize JVM Execution Context with a New Programming Library : Page 2

Applying the new programming library ATCT to asynchronous messaging and Java scripting can add some interesting new features to core Java. Learn how it works and how it can simplify your job.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

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 Java class
  • 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.

    Comment and Contribute






    (Maximum characters: 1200). You have 1200 characters left.



    Thanks for your registration, follow us on our social networks to keep up-to-date