[ACCEPTED]-How to create custom JVM?-jvm

Accepted answer
Score: 16

technically, all the information people 18 need to create a new JVM is in the public 17 specifications for the language and the 16 targetted platform. A JVM would need to 15 behave differently depending on whether 14 it is meant to run on a desktop computer 13 or a mobile phone, even if the bytecode 12 interpretation would be largely identical.

A 11 few places to start looking for information:

Reading 10 The "Java Virtual Machine Specification" by 9 Tim Lindholm

From what I have seen of JVM 8 implementations by Sun, IBM or smaller companies 7 like Esmertec, writing a simple JVM is a 6 several man-months project but adding JSR 5 after JSR to support more functionality 4 can take years afterwards.

Now, if all you 3 need is a simple bytecode interpreter, it's 2 not that bad, but it's still quite a bit 1 of code to write.

Score: 10

A handmade JVM would be a great way to learn 19 about virtual machines in general, the issues 18 of program language design (through the 17 JVM spec), and the nitty gritty of parsing 16 and so forth.

If you choose to take it in 15 that direction, you could also explore optimizations, which 14 is where it can get interesting, and you 13 can take research papers and implement their 12 algorithms.

That being said, if you're less 11 interested in the long and arduous task 10 of creating a VM from scratch, you might 9 want to modify an existing open source VM 8 like Kaffe. It will show you what a virtual machine 7 does, but not necessarily how Java code 6 works in Sun's JVM:

Kaffe is a clean room 5 implementation of the Java virtual machine, plus 4 the associated class libraries needed to 3 provide a Java runtime environment.

This 2 way, you could study the details, but dive 1 in to implementing more interesting features.

Score: 4

I understand that, currently, the big players 4 license the Java library from Sun. They 3 then add their own refinements. The main 2 difference between implementations is the 1 bytecode->machine code compiler.

Score: 3

For one thing, you may want to have a look 5 at Apache Harmony They have come a long way, so their 4 project history may actually give you a 3 good idea on the effort required. I myself 2 would not bet on it being feasible for one 1 guy

More Related questions