NPJava stands for "No-Purpose Java" - a compiler that reads Java classfiles and transforms them into x86 assembly code. This project goes against Java's core principle of portability, but it's incredibly fun to build!
Parse and understand Java bytecode from compiled .class files.
Generate native x86 assembly code for direct execution.
The entire project is implemented in Rust, leveraging its memory safety and performance characteristics for efficient compilation.
Reads and parses Java .class files, extracting bytecode, constant pool, and method information for compilation.
Transforms parsed Java bytecode into x86 assembly instructions, handling stack operations and method calls.
Deep dive into Java internals, bytecode, and assembly programming
Direct assembly output for maximum performance without JVM overhead
Building something that goes against conventional wisdom is incredibly satisfying
Excellent opportunity to practice systems programming in Rust
"NPJava goes against Java's core principle of 'write once, run anywhere' by generating platform-specific x86 assembly. It's a no-purpose project that's incredibly fun to build and teaches you about the internals of both Java and assembly programming."
Converting Java bytecode operations to equivalent x86 assembly instructions, handling the JVM's stack-based architecture.
Managing object allocation, garbage collection concepts, and memory layout in the generated assembly code.
Translating Java method calls, virtual dispatch, and exception handling to x86 calling conventions.
Processing Java's constant pool to resolve strings, classes, methods, and fields in the generated assembly.