One of the major steps I always believed that it would improve my skills in Java programming and training is learning the Java bytecode. Understanding the low level details of the Java Virtual Machine draws a bigger and deeper picture in your mind about the environment, performance tuning, security issues, reverse engineering, and much more. It also complements your Java programming language concepts, Object-Oriented concepts, and the exact definition of the various Java constructs. And one other step, learning python. Python is the language of the coming era, I believe. So what? I will write a JVM in Python!

It was a funny idea for learning both, so I decided to begin. I started reading the JVM specification, learning Python, and writing some code. 10 days later, I came out with a 90% complete JVM implementation that worked.   It was a very interesting adventure I want to share with you, download, and have a try.

Requirements

Python 2.5.X

JDK 1.6 for compiling

Installation

- Extract the pjvm.zip to your local drive. ex: C:/pjvm

Usage

- Java source files should be in the same application path. ex: C:/pjvm/Main.java

- C:\> cd pjvm

- C:\pjvm> javac Main.java

- C:\pjvm> jvm Main (run my JVM)

It does more than just saying Hello Word, but please keep in mind that I’ve implemented the JVM, not the Java SE. That’s, I did not implement Java SE APIs. For now, you can only use System.out.println() [with the different overloaded versions], and implement threading (using Runnable, do not extend Thread). But for language features, most of them are implemented. That you can declare classes, extend classes, implement interfaces, override and overload methods, define constructors and instance initialization blocks, define instance and static members, define variables and arrays of primitive and reference data types, use control-flow statements, blah blah blah.

Have a try, and thanks for feedback.

Download JVM Implementation with Python

Did you like this? Share it:

Leave a Reply

(required)

(required)

© 2012 Abdalla Mahmoud Suffusion WordPress theme by Sayontan Sinha

Switch to our mobile site