M-JVM (current version 1.03)
KVM written in Java :)
I had some free time and decided to write a JVM implementation in pure
Java :) just for fun, the main part of the work took about three days
(those was holidays).
Because the JVM (I have named it as M-JVM) has been written in pure
Java 1.1, it can be started with any JVM supports Java 1.1 or a major
version, thus it can be used from J2ME on a mobile devices (!). You
must keep in mind that it is a fun project and you use it for your own
risk (but it is an open source project). The M-JVM gives the very
good possibility for developers to use pure Java compiled class
files as scripts with full control over their execution (as you may be
know, J2ME CLDC 1.0 and CLDC 1.1 doesn't support class loaders). Also
the M-JVM can be used in listed use cases IMHO:
it can emulate the "ClassLoader" mechanism on J2ME based platforms and
you can load classes from network on mobile devices and play them (I wrote about it above but it is a good place to repeat it)
it can be used to make a virtual platform wrappers and emulate nonexist frameworks (as an example, it is potentially
possible to emulate the Android platform frameworks on a standard J2ME
device but of course it doesn't support Dalvik VM classes :) )
- it allows to increase
compression ratio because the M-JVM loads classes with an
InputStream and you can just glue many classes as one binary file (it
allows to the Jar utility to pack them really better) and load them
- many others :)
Remember please that the M-JVM doesn't support both FLOAT and DOUBLE values!!!
The framework includes three main classes (more
detailed information you can find in the JavaDoc for the
it is the core class which allows to parse class files and invoke their methods.
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 in the normal
Java :) .
it is an interface which must be implemented by a class if the class is
used as a signal processor to process actions and calls from a MJVMClass instance.
The library is distributed under LGPL and the link to load the archive
is placed below
on this page. The library archive includes sources, JavaDoc
compiled library as a JAR file. As well there are some examples which
shows the usage of the library, even a midlet shows flying blocks on a
screen (I tried to start the midlet on a real Nokia 6230 and it works
well and quickly enough). Of course I understand that the library has
been written in a not very optimally way but (as I wrote above) the
frst version was written for 3 days :) and it is one of my pet-projects
for fun thus I can't spend a lot of time for it.
shows how to write a hello world script and process its calls by a
|Vector use||The example shows how to work with Vector object from scripts||mjvm_vector_use.zip|
|Synchro||The example shows ow to work with synchronized methods and objects.||mjvm_synchro.zip|
|MJVM Stub Generator||This
utility allows to generate a java class source which 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.