[英]Where is located the native classes in Oracle Java SE JRE?
I was studying the java standard library classes and realized that some methods used the keyword native
like in the code below: 我正在研究java标准库类,并意识到一些方法使用了关键字native
如下面的代码所示:
public class FileOutputStream extends OutputStream{
private native void open0(String name, boolean append)
throws FileNotFoundException;
}
I´ve already searched and found out that it is related to JNI API
and it has to call a method in a non-java class file. 我已经搜索过并发现它与JNI API
,它必须在非java类文件中调用一个方法。 However, I´m not finding this file. 但是,我找不到这个文件。 Where is it located in this case? 在这种情况下它位于何处? Tks TKS
A native method doesn't delegate to a "method", but a native function , which doesn't reside in any kind of class file. 本机方法不会委托给“方法”,而是委托给本机函数 ,它不存在于任何类型的文件中。 Rather it's in a platform-specific dynamic-link library. 而是在特定于平台的动态链接库中。 To find the C/C++ source code of a given native method in the JDK, you must clone the Mercurial repository of the OpenJDK and spend some time getting a bearing inside the vastness of that codebase. 要在JDK中查找给定本机方法的C / C ++源代码,必须克隆OpenJDK的Mercurial存储库,并花一些时间在该代码库的广泛范围内。 I recommend using find
+ grep
a lot. 我建议大量使用find
+ grep
。
PS Oracle SE is not identical to OpenJDK, but they share 99% of the codebase. PS Oracle SE与OpenJDK不同,但它们共享99%的代码库。 Also, since the Oracle-specific delta is closed-source, this is certainly your best (if not the only) bet. 此外,由于特定于Oracle的delta是闭源的,因此这肯定是您最好的(如果不是唯一的)赌注。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.