views:

606

answers:

6

I am trying to write my own JVM. Can you point me to some existing open source implementations. Thanks.

+5  A: 

Hotspot (GPL, by Sun)

Harmony (Apache, also the basis for Android's Dalvik VM)

JamVM

CLDC - Connected Limited Device Configuration(Sun again) This one is not really open source, but the source code is available.

rq
Actually, the name of VM in OpenJDK is "Hotspot".
Pavel Shved
JamVM is probably the smallest and easiest accessible.
Thorbjørn Ravn Andersen
A: 

Definitely use the sources provided by rq, but if you are going to write a JVM consider using a register based implementation. As the paper describes, register based machines do incur instruction bloat but should be faster. And as there doesn't seem to be any register based JVM implementations out there, it would be an added bonus for writing one from scratch yourself.

+5  A: 

Check out the Alternative Java Implementations or the links page of the Kaffe VM for which you'll find an extract below (check the original site for the links):

Kaffe-based JVMs

  • Latte

    An open source JVM based on Kaffe.

  • JanosVM

    Current Utah work on multi-process JVMs.

  • KaffeOS

    KaffeOS is a Java virtual machine that allows the execution of multiple process within Kaffe. It separates the resource consumed by those processes, allows them to be safely terminated, and provides for direct sharing between processes.

    Patrick Tullman says:

    (Kaffe Core Team member Godmar Back's Ph.D. thesis) Source isn't available yet, but I think that's just because Godmar is decompressing after finishing his thesis.

  • The JESSICA Project

    Project JESSICA (Java Enabled Single-System-Image Computing Architecture) and the new JESSICA2 project are all based on Kaffe to create a distributed JVM for running multithreaded Java applications on PC clusters.

  • Gilgul

    • Gilgul is a compatible extension of Java. * It introduces a new view on the concept of object-identity. * It allows for dynamic object replacement by simultaneously rerouting a set of references as an atomic operation. * It thus provides means for unanticipated software evolution
  • Alta

    The Alta Virtual Machine is a Java-compatible Virtual Machine designed to provide nested process services to Java applications. Alta is based on Kaffe.

  • Guaraná

    Guaraná is a reflective architecture that aims at simplicity, flexibility, security and reuse of meta-level code. It uses Kaffe as its base. Guaraná is available for download under the GPL.

  • kangaroo

    kangaroo is a J2ME/CLDC alike Virtual Machine.

Free Software JVMs

  • Red Hat Sourceware Project for the Java Language (gcj).

    Red Hat (who bought Cygnus) is developing a complete free software toolkit for developing in the Java Language. gcj is part of the egcs project and provide as Java front-end and a set of run-time libraries to egcs. Also includes the gij interpreter.

  • jRate

    An extension of the GNU GCJ compiler front-end and runtime system which adds support for most of the features required by the Real-Time Specification for Java (RTSJ).

  • ORP (Open Runtime Platform)

    From Intel.

  • Jikes Research Virtual Machine (RVM)

    A free, self-hosting virtual machine (written in Java!)

  • JC

    A virtual machine written in Java that converts Java bytecode to C before running it. (from Kaffe project alumni Archie Cobbs)

  • Japhar

    Japhar is the Hungry Programmers' Java VM. It has been built from the ground up without consulting Sun's sources. Japhar is LGPLed and available for download.

  • ElectricalFire

    ElectricalFire is an open source project that came from a cancelled commercial project at Netscape and is now sponsored by Netscape under the Mozilla umbrella.

    ElectricalFire is a Java Virtual Machine that uses JIT (Just In Time) compilation techniques to accelerate Java code execution. ElectricalFire was designed from the start to generate high-performance machine code and to be portable to many different processor architectures.

  • Waba

    A small JVM aimed at portable devices.

    Also, Wabasoft, and SuperWaba.

  • joeq Virtual Machine

  • kissme Virtual Machine

  • SableVM

  • Wonka

    A cleanroom Virtual Machine for the Java(tm) language, originally developed by telematics specialists ACUNIA .It is extremely portable and self-contained, and can optionally be used with its own real-time executive (OSwald(tm)) to provide a complete solution for embedded devices.

    Also, the chief arhitect of WonkaVM, Chris Gray, funds a company to provide embedded java solutions named as Mi|k|a(TM).

  • JamVM

  • Jupiter

  • IKVM

    A Java Virtual Machine for .Net!.

  • Java Pathfinder

    A runtime Java program verification / model checker tool from NASA that is actually a state matching, backtracking JVM that is a model checker that is written in and runs on top of Java! It can (with Kaffe project alumni Peter Mehlitz)

  • Aegis VM

    The Aegis VM Projects is an on-going effort to develop a lightweight, secure virtual machine for executing Java bytecode. The VM is intended to be an extension framework for applications or devices that dynamically load and execute untrusted extensions.

  • JAOS (Java on Active Object System)

    A Java virtual machine for the AOS system and a case study in interoperability between the Oberon and Java languages.

  • CACAO

    A research Java Virtual Machine developed at the Vienna University of Technology and released under the GPL. The VM uses a compile-only approach, which means there is no interpreter available. The optimizing JIT compiler is available for a number of architectures.

  • Ovm Project

    An open source framework for building programming language runtime systems. Ovm is a DARPA funded collaborative effort between Purdue University, SUNY Oswego, University of Maryland, and DLTech. The current emphasis for Ovm is to produce a Java VM compliant with the Real-Time Specification for Java.

  • Mysaifu JVM

    A Java VM which runs on Windows Mobile 2003 software for Pocket PC (Pocket PC 2003) licensed under the GPLv2 (GNU Public License Version 2).

  • DynamicJava

    A Java source interpreter, written in Java.

  • Ghost Machine

    For the Palm.

  • JNode

    A LGPL JVM and operating system written in Java, with a JIT-like native code compiler and bytecode interpreter. No C code - just Java and assembly!

  • JX-OS

    A GPL'd system architecture consists of a set of Java components executing on the JX core that is responsible for system initialization, CPU context switching and low-level domain management. The Java code is organized in components which are loaded into domains, verified, and translated to native code.

  • JAmiga

    A GPL'd JVM for the Amiga.

  • Kabavm System

    A tiny Java Runtime targeted in small hardware devices. See Japanese webpage for details.

  • NanoVM

    A tiny java virtual machine for the Atmel AVR ATmega8 CPU, the member of the AVR CPU family used e.g. in the DLR Asuro robot.

  • Hormony (wiki)

    Apache Foundation's effort to create a new cleanroom J2SE-compatible environment, and Geir Magnusson Jr. wrote a proposal and this wiki page for details.

Ports of Sun's JDK

  • Sun Microsystems - java.sun.com

    Where Java comes from in the first place. They also have a list of official ports.

  • Java for FreeBSD

    This is an unsupported version of Sun's Java Development Kit ported to FreeBSD. It is being tested for any problems that might exist. No known significant bugs exist at this time, but there are no guarantees of usability.

  • Blackdown JDK for Linux

    The Blackdown JDK is a port of Sun's Java Developer's Toolkit to Linux.

Both lists aren't up-to-date and initiatives like OpenJDK or Apache Harmony are missing.

That said, I don't know what you mean exactly by "good open source implementations". Good doesn't mean the same thing for everyone and may depend on the context. Kaffe is a great choice as a base for virtual machine education and/or research, IBM's Jikes has a very fast compiler, OpenJDK may be very mature but might not be the best choice for educational purposes, etc. They are all good implementations but I don't know which one is the "better" for you. Actually, I'll let you decide.

Pascal Thivent
+3  A: 

I don't think, the openjdk sources are a good starting point to learn writing a VM. It's just too big and too platform specific. There alternatives around like:

  1. It is said, the Parrot VM is capable running Java Bytecode. Parrot VM is already register based.
  2. Projekt shark (within openjdk it project zero) is a portable "fork" of the OpenJDK without the assembler sources. It uses the LLVM as far as i know. On http://gbenson.net/ there are information about how to build an debug it.
  3. The LLVM project has as an incomplete JAVA frontend.
  4. Sun is rewriting the JVM in JAVA itself. It's called Maxine and it is considered for research. See http://wikis.sun.com/display/MaxineVM/Home for more information.

There is a good Wikipedia entry about alternative JVM implementations. Some of them are already mentioned here, some aren't.

dz
+1 for the link to Maxine. Interesting.
serg10
A: 

If you like something a little more exotic & high-level, IKVM is an open-source JVM built on the mono/.NET CLR.

RAOF
+1  A: 

Here are two toy JVMs:

binil