MCPcopy Index your code
hub / github.com/zxh0/jvm.go

github.com/zxh0/jvm.go @main sqlite

repository ↗ · DeepWiki ↗
1,917 symbols 5,476 edges 347 files 392 documented · 20%
README

jvm.go

A JVM written in Go. jvm.go Logo

Introduction

jvm.go is a toy JVM (which is far from complete) programmed in Go. The main purpose of this project is learning Go and the JVM. So the number one goal of the project is readability of code. The basic idea is to just implement the core JVM, and use rt.jar (from OpenJDK) as its class library. The garbage collector is implemented by directly using Go’s GC.

My dev environment

  • Mac OS X 10.13.6
  • Java 1.8.0_201
  • Go 1.12

Build jvm.go

git clone https://github.com/zxh0/jvm.go.git
cd jvm.go
go build github.com/zxh0/jvm.go/cmd/java

Run jvm.go using your Java installation

Check your Java version and ensure JAVA_HOME env was set

./java -XuseJavaHome -cp path/to/jars:path/to/classes HelloWorld

Run jvm.go using Zulu

Download zulu jdk 8 (Zulu is a certified build of OpenJDK that is fully compliant with the Java SE standard.) and unzip it to somewhere, Copy jvm.go/java into unzipped folder

cd path/to/zulu8-macosx
cp path/to/jvm.go/java jvmgo
jvmgo -cp path/to/jars:path/to/classes HelloWorld

Extension points exported contracts — how you extend this code

Instruction (Interface)
(no doc) [12 implementers]
instructions/base/instruction.go
If1 (Interface)
(no doc) [3 implementers]
test/testclasses/src/main/java/jvm/lambda/InterfaceMethodTest.java
Module (Interface)
TODO
module/module.go
AttributeInfo (Interface)
* attribute_info { u2 attribute_name_index; u4 attribute_length; u1 info[attribute_length]; } */
classfile/attribute_info.go
ConstantInfo (Interface)
* cp_info { u1 tag; u1 info[]; } */
classfile/constant_info.go
Entry (Interface)
(no doc) [2 implementers]
classpath/entry.go
Method (FuncType)
NativeMethod
native/registry.go
OnPopAction (FuncType)
(no doc)
rtda/frame.go

Core symbols most depended-on inside this repo

GetRefVar
called by 97
rtda/local_vars.go
PushInt
called by 85
rtda/operand_stack.go
ReadUint16
called by 79
vmutils/bytes_reader.go
PushRef
called by 70
rtda/operand_stack.go
_unsafe
called by 64
native/sun/misc/Unsafe.go
Register
called by 58
native/registry.go
GetIntVar
called by 52
rtda/local_vars.go
NewRefSlot
called by 45
rtda/heap/slot.go

Shape

Function 833
Method 761
Struct 164
Class 129
Interface 17
TypeAlias 11
FuncType 2

Languages

Go79%
Java21%

Modules by API surface

instructions/comparisons/if.go34 symbols
instructions/conversions/x2y.go32 symbols
instructions/math/iop.go31 symbols
instructions/math/lop.go29 symbols
rtda/heap/class_loader.go28 symbols
rtda/heap/class.go28 symbols
rtda/operand_stack.go26 symbols
classfile/access_flags.go24 symbols
native/sun/misc/Unsafe_memory.go23 symbols
native/sun/misc/Unsafe_object.go22 symbols
test/testclasses/src/main/java/stdlib/basic/sunmisc/UnsafeObjectTest.java21 symbols
native/java/util/zip/ZipFile.go19 symbols

Dependencies from manifests, versioned

github.com/docopt/docopt-gov0.0.0-2018011123173 · 1×

For agents

$ claude mcp add jvm.go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact