Where can I see the source code of the Sun JDK?

Solution 1:

Install the Java SE Development Kit from http://java.sun.com/javase/downloads/index.jsp.

Once installed, you should find an archive called src.zip in the top of the JDK installation directory. The Java source code is in there.

The file is java/util/LinkedList.java.

update: You may also like to visit the online OpenJDK Source repository. See this answer below.

Solution 2:

You have the source in the docjar:

LinkedList.java (from the openjdk-7)

Solution 3:

The sources are hosted at hg.openjdk.java.net. You can find the library sources for a specific JDK version under src/share/classes. For example, the JDK 8 source for java.util.LinkedList is located at:

hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/tip/src/share/classes/java/util/LinkedList.java

You can follow the instructions here to explore the source.

Solution 4:

grepcode.com has source code of almost all opensource projects. It also provides common IDE features like find usages, derived types, etc.

Here you can find LinkedList source: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/util/LinkedList.java/

Solution 5:

As previously said, you have a src.zip file installed with Sun JDK if you have selected it during installation. Moreover, if you use eclipse and add a JDK to your JRE list, it will attach automatically the sources to the jar and if you try to open a class with Ctrl+Shift+T (Open Type), you type LinkedList, and it will show you the code of the class.