May 2, 2014
This is a Java Virtual Machine implementation written in Racket. This implementation is able to run code compiled using the standard java compiler with partial support for the standard Java library.
The HelloWorld.java source code:
The HelloWorld.class bytecode:
The Racket.java source code:
The Racket.class bytecode:
The racket jvm execution:
With execution information:
- Data abstraction was used to represent references and values
- Information about class files and other objects is accessed through message passing.
- Recursion is used to create class references and lists, as well as for execution of instructions.
- For opening and loading files from jar files, the file/unzip package was used.
- For information about the class file format, the The Java Virtual Machine Specification page on oracle.com was used.
- To compile java source files, the standard java compiler was used.
This project takes a well established virtual machine (the JVM) and re-creates it in another well established virtual machine (Racket) to double the amount of virtualization. By combining these two VMs a user can explore how the JVM works with detailed output from the Racket VM. This is very useful when debugging or studying execution paths of a java program.
Technology Used Block Diagram
This JVM only has partial support for the java standard library. This is due to the fact that many of the core functions in java are actually native functions which take advantage of the Java Native Interface. These functions execute code inside of shared libraries and are what allow Java to be multi-platform.
Because this JVM does not support the Java Native Interface, I have instead mapped native methods to functions within racket. One example of this is the Racket.display(String str); function. When this function is invoked in the bytecode, the display function in racket is executed with the arguments of the call.