86

Is JVM open source code? If not, how can I get the code of JVM?

1
  • 1
    JVM is a specification ! Which has different implementations Commented Aug 4, 2020 at 15:26

4 Answers 4

71

It depends entirely on which JVM you use.

If you use the OpenJDK JVM, then you can get the source code from here (or here from a list of OpenJDK projects, or here from a list of GitHub mirrors).
If you use the Kaffe JVM, you can get the source from here.
If you use the Sun JVM version 6 or later, then you can get the source from here.

If you use a Sun JVM earlier than 6, then you can often get the source under an academic license. If you use an IBM, Oracle, HP, or other JVM, then the source is not open.

Update May 2013

The Version 6 source can still be accessed by the above link, or it can be accessed via this link. This latter link also includes a handy genealogy table that shows how the Oracle JDK and OpenJDK versions match with each other.

Additionally, a more up to date version of the Java 7 source can be found here. This also includes the fixes for the releases of Java 7 since GA.

And, of no surprise to anyone, the Java 8 sources can be found here.

Sign up to request clarification or add additional context in comments.

Comments

43

Have a look at hotspot JVM here: http://openjdk.java.net/groups/hotspot/

4 Comments

However, the best place to start leading how Java run is the src.zip and only after you are familiar with most of the key classes there would you move on to the hotspot module.
@PeterLawrey May I ask you some? After looking at the src\share\native\java\lang\Thread.c I figured out that the implementation of the native method interrupt0 is dug in JVM_interrupt. Where can I find the source for it? Is that from the hotspot?
seems the repository browsing link there doesn't work. This does: github.com/openjdk-mirror/jdk7u-hotspot
Answers should not consist out of a mere link
1

The core part of the JVM is in the hotspot module of the OpenJDK. However what you need is more likely to be in src.zip.

The hotspot module apart of those classes is

  • mostly in C++
  • not always easy to understand. This has improved over the years and new code tends to be better as they are more aware that the code will have broader consumption.
  • often not what you are looking for.

For this reason if you want to know how the JVM runs it is best to look at the commonly used classes. For example, even something as low level as how lambdas really work at runtime is mostly in the src.zip not much is in the JVM.

Most of the source for the libraries come with the JDK in the src.zip file. Your IDE will use that automatically. You are much better off being familiar with the classes in these libraries than playing with the JDK itself.

15 Comments

giri was asking about JVM, not JDK.
Yes he wanted the JVM and not of the JDK source, so you get now a down.
I double checked again, only for you. No, the sources of the JVM (the so-named hotspot JVM, the java bytecode interpreter) isn't in src.zip . In src.zip, is there only the source code of the JDK, which is the standard system library collection. You really don't understand the difference?
The OP asked for the source code of the JVM. It is not there, it is in a mercurial repository by the oracle's public web. Have you ever seen this src.zip? In your life? Ever?
I think there is a very simple sane answer: "I am sorry, maybe I really misunderstood this question before 4 years", and then I answered, "no problem, bro". I was only upset after finding this question by google, and finding 4 BAD answers in a row, all of them from old, 20k+ SE users.
|
-5

There is no open source jvm even if there were you can't bypass Oracle's stupid classpath exception. In short openjdk is still tied to $$ driven scheme that forces you to contend with a comercial vm. No different from Microsoft really, you can work with C# under what ever os they even provide .net libraries free but maintain control over Visual Studio which practically forces the end user to make use of Windows as the chosen environment.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.