Master the fundamental concepts of jvm internals through this focused micro-challenge.
Running \`Hello World\` on a toy JVM requires class parsing, constant pool resolution, and a bytecode interpreter for a handful of opcodes. Real HotSpot adds tiers, GC, and intrinsics; the core loop is the same fetch-decode-execute pattern as your bytecode VM.
Minimum capabilities:
Native methods (\`System.out\`) can be stubbed: when bytecode hits \`getstatic\` on \`out\`, return a handle your runtime recognizes.
For example, \`getstatic java/lang/System.out\` followed by \`ldc "Hello"\` and \`invokevirtual println\` is the entire program path.
Frame setup mirrors the JVM spec: local array sized from \`max_locals\`, operand stack from \`max_stack\`.
Stub native methods with logging first so you know which host calls fire during Hello World. Real JVMs map hundreds of natives; a toy runtime can fake `println` with a single special case.
This exercise asks you to implement a minimal JVM that loads one class and runs \`main\`. You will parse enough of the class file and interpret enough opcodes to print Hello World.
You will use the same mental model here when reading production interpreter source later in the track. Sketch one concrete input on paper, predict the outcome, then confirm with code. That discipline catches logic errors early and makes debugging far faster when you extend the implementation in follow-on tasks.
Write a C program that implements a minimal JVM interpreter executing a Hello World bytecode sequence.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github