The method is implemented in "native" code. That is, code that does not run in the JVM. It's typically written in C or C++.
Regular Java class definitions are compiled to bytecode, held in class files. This bytecode is platform independent, and is translated into specific instructions for the architecture and operating system running the bytecode at run time.
Java native code necessities
1. We need to run some platform-specific code, perhaps referencing a platform specific library or making some operating system–level calls, or making some operating system–level calls.
2. Hardware access and control.
3. Use of commercial software and system services[hardware related].
4. Use of legacy software that hasn't or cannot be ported to Java.
5. Using native code to perform time-critical tasks.
A native method is well-defined header in C or C++, identifying the class name, the Java method name, as well as its parameters and return type. When your code is loaded into the JVM, you need to register your native code so that it knows exactly what needs to be run when your native method is called.
No comments:
Post a Comment