Where are the native classes located in the Oracle Java SE JRE?

I was looking into the standard java library classes and realized that some methods were using the keyword native

like in the code below:

     
    public class FileOutputStream extends OutputStream{

    private native void open0(String name, boolean append)
        throws FileNotFoundException;
}

      

I have already searched and found out what it is related to JNI API

and it should call a method in a non java class file. However, I don't find this file. Where is he in this case? Tks

+3


source to share


1 answer


A native method does not delegate a "method", but a built-in function that is not found in any kind of class file. Rather, it is in the dynamic link library for the platform. To find the C / C ++ source code for a given native method in the JDK, you have to clone the Mercurial OpenJDK repository and spend some time getting a foothold within the vastness of that codebase. I recommend using find

+ a grep

lot.



PS Oracle SE is not identical to OpenJDK, but they have 99% of the codebase. Also, since the Oracle-specific delta is closed source, this is by far your best (if not the only) bet.

+2


source







All Articles