jvm.go is a new JVM(which is far from complete) programmed in Go. The main purpose of this project is learning Go and JVM. So, the number one goal of the project is readability of code. The basic idea is just implement the core JVM, and use rt.jar(from OpenJDK) as its class libraries. GC is directly using Go's. For me, the hardest part is Thread and ClassLoader.
- Mac OS X 10.10.2
- Java 1.8.0_31
- Go 1.4
go get github.com/zxh0/jvm.go/jvmgoCreate the following folder and file structure:
$GOPATH/bin
├── jvmgo
└── jre/
└── lib/
├── rt.jar
├── currency.data
└── net.properties
jvmgo -cp path/to/jars:path/to/classes HelloWorld/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/jre/lib/rt.jarCreate a java source file: Main.java
public class Main {
public static void main(String []args){
String val = "hello world";
if(args != null && args.length > 0){
val = args[0];
}
System.out.println(val);
}
}Compile Main.java, it will generate Main.class
javac Main.javaRun with jvmgo
jvmgo MainOutput
hello world