SourceForge.net Logo

Java Hibernation Package

What is it?

Java Hibernation Package is an experimental implementation of thread (de)serialization mechanism based on the Java Platform Debugger Archtecture(JPDA). You can capture snapshots of execution at any time. Then you can resume the execution later from one of them.

Ability of externalizing computation (and back) enables us to make systems fault-tolerant(via checkpointing), or to balance loads in distributed computing systems. In the context of Java, such ability corresponds to the one of thread (de)serialization, which is not inherent in standard Java runtime systems.

So far, several thread (de)serialization systems are proposed. Some implemented it by modifying existing virtual machine implementations, or reimplementing Thread-related classes through JNI. And some achieved it by way of source code (or bytecode) tranformations. However, it is not an easy task to maintain the modified version of JVM or classes, following state-of-the-art JVM implementations. Also it is almost impossible to implement (de)serialization of (possibly multiple) threads without performance penalty by the code transformation-only approach.

The project's choice is similar to the one of Illmann et al. [5th International Conference on Mobile Agents, 2001]. By making use of JPDA, we can easily capture necessary state (such as program counter, heap, and call stacks) and pack them into ordinary Java objects. Moreover, if you use Sun's recent HotSpot VMs, state capture will not affect the performance of nomal executions due to the dynamic de-optimisation technique. On the other hand, resuming execution from any given state is not directly supported even by recent JVMs. We need some bytecode engeneering in cooperation with analysis of operand stack type (also done by bytecode verification) to achieve that.

How does it work?

PREPARATION

Original class files
For a target application, we need its class files with debug information(with -g option of javac).
Static hack
The class files are analyzed and transformed. For each methods, correct type of STOREs and LOADs are inserted just before selected stack consuming instructions (currently, only invoke instructions) to store the content of the operand stack. This is necessary because we cannot capture the operand stack by JPDA.
Execution
The target application must be launched by class `Bootup' in the Java Hibernation Package.

HIBERNATION

Suspension
Suspends the execution by the API method 'suspend' of Java Debug Interface(JDI) which is a part of JPDA.
State capture and dump
The execution state is captured by JDI and encoded into an ordinary java object of class `PState', then dumped to a file by the standard serialization mechanism.

RESUMPTION

Dynamic hack
The system transforms the (statically hacked) class files. By using information of the state file, TABLESWITCHs are inserted to the methods for program counter reconstruction. (for more details, see Illmanns' paper)
Transcription
Through the early bootup stage, the state encoded in PState objects is transcribed to the VM via JDI.

Current limitations

Distribution

You can get the source distribution from SourceForge. The distribution consists of the following sub-directories:
hacked_sys hacked versions of system classes (hibernation system will generate more, if necessary)
jdfa contains scripts and a patch to build Data-Flow Analysis Framework for Java(jDFA) for our package
mobilesocket contains build scripts and a patch to build MobileSocket for our package
script python scripts to utilize the package
src the source tree
test several test programs

Build and test

I have tested the package in a Linux environment. I believe that the package will also work in other environments such as Mac OS X or Windows. The following are necessary to build Java Hibernation Package: The last two will be automatically downloaded, patched, and built early in the whole build process. To build the package, do the following:
  1. Edit `script/env.py' and set 'default_bcel_path' and 'default_jdi_path' correctly.
  2. Type `make' at the top directory. A JAR file 'usx.jar' should be created in the top directory.
  3. Then you can try some test programs in the `test' directory, e.g.:
    cd test/loop
    make. . .build test application
    make hibernate. . .test application starts, then hibernates in several seconds
    make dump. . .captured state is shown
    make resume-hibernate. . .test application resumes, then hibernates again in several seconds
    make resume. . .test application resumes

Author

Masatomo Hashimoto

This project was derived from a part of a research entitled 'Ubiquitous Programming Language System' by the author. It was carried out as an individual research of the PRESTO program ( Information and Systems) by Japan Science and Technology Agency.


© 2006 Masatomo Hashimoto