public native int hashCode () first saw this word native?
Java Native Interface (JNI) is a standard mechanism for running code under the control of the Java virtual machine (JVM), which is written in C / C++ or Assembler languages, and is linked in the form of dynamic libraries, eliminating the use of static linking. This makes it possible to call a C / C++ function from a Java program, and vice versa.
How do you understand that the C language “is” in Java?
Answer 1, authority 100%
A rather old infa, however, explains quite clearly:
If, in the process of implementing a Java project, it becomes necessary to use existing code written in another programming language, or use low-level functions to directly access computer hardware, it is possible to resort to the so-called
native methods, which can be called from within the Java application environment, but are created in one of the “related”
(native) languages, usually C or C++. Native methods are declared with the native modifier. The body of the method is implemented in another language and therefore is replaced with a semicolon in the declaration. The following is an example of a method declaration that queries the operating system for the processor identification number of the host computer.
public native int getCPUID ();
The only difference between native methods is that they are implemented in another programming language. Otherwise, they are similar to conventional methods, i.e. can be overridden, overloaded and supplied with any modifiers –
final, static, synchronized, public, protected or private (except abstract and strictfp) .
When accessing native methods, the portability and security features inherent in Java code will be lost. It is almost impossible to use
native methods in Java code that is designed to be downloaded from the Internet or run on remote computers on the network (Applets are an example). It is possible that a completely different system architecture will have to work with your code, but even if this is not the case, the system may simply prohibit the execution of untrusted code.
native methods are implemented using API libraries provided by Java virtual machine developers for specific platforms. One of the standard API libraries for C programmers is
JNI , from
Java Native Interface . There are libraries for other languages as well.