Where to find the source code for java.lang inline methods?

I am vaguely familiar with JNI , and am curious to see my machine-specific implementation of some native methods in java.lang. Thread#currentThread() , for example.

I found a bunch of DLLs in [JDK_HOME] / jre / bin, but as I said, I'm trying to find the source code.

Does anyone know where to find the native source code? Is it even affordable or classified by Sun (oops I mean "We are in it to win this" Oracle)?

+54
java native jni java-native-interface
Feb 18 '10 at 22:13
source share
2 answers

For JDK6, you can download the source code from java.net . For java.lang story begins with j2se/src/share/native/java/lang/ and then the search ... JDK7 reorganizes the directory structure a bit.

Some methods, such as Object.hashCode , can be implemented as a hot spot instead or in addition to via JNI / Java.

JDK6 is freely licensed through the Java Research License (JRL) and Java for Internal Use (JIUL). JDK7 and OpenJDK6 are licensed under the GPL 2 license with the exception of CLASSPATH (roughly speaking, you can refer to it without intercepting the GNU virus). I am not a lawyer.

( By the way: real lawyers would like to point out that I'm still working at Sun Microsystems. Sun UK is no longer there. Now it's Oracle.)

Update (adding location for Thread.c): http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f96a0f/src/share/native/java/lang/Thread.c

+34
Feb 18 '10 at 22:43
source share

You can see the OpenJDK source code (licensed under GPLv2 with the exception of Classpath ). Probably the best way to learn the internal JDK implementations is if you do not want the associated Java Research License , in which case you can access the actual JDK 6 source .

+11
Feb 18 '10 at 22:18
source share



All Articles