So I came across a method like this in some source
public native void method();
There was code inside, but it was commented out,
/*MANUAL code code code */
The code looked a bit like C++.
So what does this mean? I know it does something because eventually it was called in the class...
Answer
That's a declaration for a native method, indicated by the native modifier, as explained in the Java Language Specification, section §8.4.3.4 native Methods .
You won't find its implementing code in Java, it's referring to code that's either in the C libraries that are part of the implementation of the JDK in use, or part of a native library bundled with the code you're studying. Refer to the JNI documentation to understand how this gets called from a Java program.
No comments:
Post a Comment