I had written a JVM implementation in Java and called it
MJVM.
Because the framework written with Java 1.1, it can be started on any
Java since 1.1 or later, as you see it can be used on mobile
devices with J2ME or iTV devices. The framework gives very
good possibilities for a developer to use pure Java compiled class
files as scripts with full control over their execution. The framework
gives can be used in a lot of use cases as an example:
-
it can emulate the "ClassLoader" mechanism on J2ME based platforms and
you can load classes from network on mobile devices and play them.
-
it can be used to emulate a platform (as an example, it is potentially
possible to emulate the Android platform on a standard J2ME
device with the framework :) )
- it allows to increase
compression ratio because the framework loads classes from an
InputStream and you can glue a few classes in one binary file (it
allows the Jar utility to pack them really better) and load them
sequentially.
- many others :)
The framework includes three main classes (more
detailed information you can find in the JavaDoc for the
library):
- MJVMClass,
it is the core class which can parse class files and invoke theitr methods.
- MJVMObject,
the class describes an object instance for a "virtual" class and
contains class field values. It can be considered as an analogue
of the java.lang.Object class in
Java.
- MJVMProcessor,
it is an interface which must be implemented by a class which will be
used as a signal processor to make actions and outside calls from a MJVMClass instance.
The library is distributed under LGPL and it can be downloaded below
from ths page. The library archive includes sources, JavaDoc
and
compiled library as a JAR file. As well there is the source of the
sample midlet which uses a Java class file as a script to
drive
blocks on the screen. I had tested the midlet on different emulators
and a real Nokia 6230 device and it worked well and pretty
quickly. Of course I understand that the library is not very optimally
written but the frst version had been written in 3 days :) (I wrote all the
project in my weekend). You should understand that it is one from my home pet
projects and I can't spend a lot of time for it, so I am not sure that
new versions of the library will be produced very often.
| Examples |
| Hello world! |
It
shows how to write a hello world script and process its calls to a
MJVMProcessor |
mjvm_hello_world.zip |
| Vector use | The example shows how to work with Vector object in scripts | mjvm_vector_use.zip |
| Synchro | The example shows ow to work with synchronized methods and objects. | mjvm_synchro.zip |
| Utilities |
| MJVM Stub Generator | This
utility allows to generate a java class source that implements the
MJVMProcessor interface. The generated class can be used to process
calls from a MJVMClass object. | mjvmgen_100.zip |
© 2003-2010 Igor A. Maznitsa. All Rights reserved.