Normally, in order for the JVM to find your native functions, they have to be named a certain way. e.g., for java.lang.Object.registerNatives, the corresponding C function is named Java_java_lang_Object_registerNatives. By using registerNatives (or rather, the JNI function RegisterNatives), you can name your C functions whatever you want.
Here’s the associated C code (from OpenJDK 6):
static JNINativeMethod methods[] = {{“hashCode”, “()I”, (void *)&JVM_IHashCode},{“wait”, “(J)V”, (voi......
阅读全文