在哪里可以找到java.lang本机方法的源代码? [英] Where to find source code for java.lang native methods?
问题描述
我模糊地熟悉 JNI ,我很想看到我的机器 - java.lang包中某些本机方法的特定实现。 Thread#currentThread()
,例如。
I'm vaguely familiar with the JNI, and I'm curious to see my machine-specific implementation for some native methods in the java.lang package. Thread#currentThread()
, for example.
我在[JDK_HOME] /中发现了一堆DLL jre / bin,但就像我说我正在尝试查找源代码。
I've found a bunch of DLLs in [JDK_HOME]/jre/bin, but like I said I'm trying to find the source code.
有谁知道可以找到原生源代码的位置?它是否可用,或者它是否被Sun分类(oops我的意思是我们在其中赢得它Oracle)?
Does anyone know where the native source code can be found? Is it even available, or is it classified by Sun (oops I mean "We're In It To Win It" Oracle)?
推荐答案
对于JDK6,您可以从 java.net 下载源代码。对于 java.lang
,故事从 j2se / src / share / native / java / lang /
开始,然后搜索... JDK7稍微重新排列目录结构。
For JDK6 you can download the source from java.net. For java.lang
the story begins at j2se/src/share/native/java/lang/
, and then search... JDK7 rearranges the directory structure a little.
某些方法,例如 Object.hashCode
,可能是通过热点实现,或者通过JNI / Java实现。
Some methods, such as Object.hashCode
, may be implemented by hotspot instead or in addition to through JNI/Java.
JDK6通过Java研究许可证(JRL)和Java内部使用许可证(JIUL)免费许可。 JDK7和OpenJDK6在GPL 2下获得CLASSPATH异常许可(粗略地说,您可以链接到它而不会捕获GNU病毒)。我不是律师。
JDK6 is freely licensed through the Java Research License (JRL) and Java Internal Use License (JIUL). JDK7 and OpenJDK6 is licensed under GPL 2 with CLASSPATH exception (roughly speaking you can link to it without catching the GNU virus). I am not a lawyer.
( BTW:真正的律师想指出我仍然是Sun Microsystems的员工。 Sun英国已不复存在。它现在是 Oracle。)
(BTW: The real lawyers would like to point out that I am still an employee of Sun Microsystems. Sun UK is no more. It is now Oracle.)
更新(为Thread.c添加位置):
http:// hg。 openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f96a0f/src/share/native/java/lang/Thread.c
Update (Adding location for Thread.c): http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f96a0f/src/share/native/java/lang/Thread.c
这篇关于在哪里可以找到java.lang本机方法的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!