在哪里可以找到 java.lang 本地方法的源代码? [英] Where to find source code for java.lang native methods?

查看:36
本文介绍了在哪里可以找到 java.lang 本地方法的源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 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]/jre/bin 中找到了一堆 DLL,但正如我所说,我正在尝试查找源代码.

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 分类(哎呀,我的意思是我们要赢得它"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.

(顺便说一句:真正的律师想指出的是,我仍然是 Sun Microsystems 的员工. Sun UK 已不复存在.它现在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆