Identify library file/Source that contains native

2019-03-06 15:56发布

问题:

How to identify library file that contains implementation of native methods ?

Ex.

public native String intern();

Where can I find implementation (source code) of String.intern() method ?

回答1:

Found answer for String.intern() with quick google search

  • constant pool
  • symbol table cpp : symbol table hpp

Yet to find answer for generic way to identify native implementation/library



回答2:

Download this JDK 6 library:

http://download.java.net/jdk6/source/

and search through sources.

But I think, some code implementations are not accessible as OpenSource



回答3:

There is no general approach to find source code for (any) native method. But if we narrow the question to the native jre methods, then you can find some implementations in the (full) source code of openJdk.

Just keep in mind that those are the implementations for just one JRE, other implementations of Java may have different implementations of the native methods.

To find the source for a native method: search the repository for the JNI header files, then you should get the name of the C/C++ function that provides the implementation.