Good day to all! I have a question about the following character. I still can’t understand exactly where the implementation of native methods is stored, which come with a standard API from Oracle (formerly Sun Microsystems). Let me give you a concrete example! We have a System class from the java.lang package. When we first access this class, for example, when calling the System.out.println () method, the static fields of this class are initialized (that is, static initializers and code that is inside the static initialization blocks are executed). So, first of all, the following code is executed:

static { registerNatives(); } 

where registerNatives () is a static native method. As far as I know, the implementation of such methods is described in other programming languages, such as C / C ++, FORTRAN and assembly languages. But I don’t know where to see the code itself, but I would like to do it! I am by nature a very meticulous person, I want to know how everything works! I would be grateful for all the help!

    1 answer 1

    The implementation is stored in the JVM itself, and the code can be viewed in its source code .