Native methods that are implemented within the JVM may circumvent the full-blown JNI interface by calling these functions.
Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
Definition in file native.h.
Go to the source code of this file.
Functions | |
ARCH_COPYRIGHT_APACHE (native, h,"$URL: https://svn.apache.org/path/name/native.h $ $Id: native.h 0 09/28/2005 dlydick $") | |
jvm_native_method_ordinal | native_locate_local_method (ClassFile *pcfs, jvm_constant_pool_index clsnameidx, jvm_constant_pool_index mthnameidx, jvm_constant_pool_index mthdescidx, rboolean find_registerNatives) |
Associate class name string with its local native method interface connection. | |
rvoid | native_run_method (jvm_thread_index thridx, jvm_native_method_ordinal nmord, jvm_class_index clsidx, jvm_constant_pool_index mthnameidx, jvm_constant_pool_index mthdescidx) |
Invoke a native method, either local or full JNI. |
|
|
|
Invoke a native method, either local or full JNI. Local native methods are normally called through this interface using their ordinal number assignment. Normal JNI native methods are invoked with the JLOBJECT_NMO_NULL ordinal and with normal class and method information.
Invoke JNI methods, not local native methods
env = make_JNIEnv_pointer_from_pjvm(); (to be done during jvm_init() at startup)
System.LoadLibrary("SomeJniMethodLib.so"); (to be done in Java class initialization, requires registerNatives(); (to be done in Java class initialization) void *pjni = method_resolve_jni(clsidx, mthnameidx, mthdescidx); (Recommend adding this function in this source file for this purpose.) Finally, invoke JNI method, per return type. The parameters are on the the JVM thread's STACK() now, so simply reference the stack frame for the parameter list. To be decided: How to take the return code and pass it back out. Suggest doing the same thing as the local native methods by capturing its value, POP_FRAME(), then PUSH(rc). (*pjni)(&GET_SP(thridx)); ... (jvoid) jint rc = (*pjni)(&GET_SP(thridx)); jfloat rc = (*pjni)(&GET_SP(thridx)); jlong rc = (*pjni)(&GET_SP(thridx)); jdouble rc = (*pjni)(&GET_SP(thridx)); POP_FRAME(thridx); PUSH(thridx, rc); ... adjusted for return type The only problem with this for now is that the STACK() in this implementation is a push-UP stack, which means that the first item pushed has the lowest real machine address. Many stacks are a push-DOWN type, which means that the last item pushed has the lowest real machine address. This will need to be examined to see how it affects the JNI implementation connectivity to the library. It should not be too much of a problem to change the STACK() implementation to be push-DOWN, but if JNI is a highly modular interface, then this implementation of it should be handle either type of STACK() with equal facility. < Signed byte < Unicode character < Integer < Signed short < Boolean, true or false < Long integer < an instance of class '/class/name' < Double-precision floating-point value < Single-precision floating-point value < Reference to one array dimension < No return type, instead: (rvoid) fn(p1,p2,...)
Invoke local native methods that return (jvoid)
< No
< No Invoke local native methods that return (jobject), known to this implementation as (jvm_object_hash).
< No Invoke local native methods that return (jint)
< No Invoke local native methods that return (jfloat)
< No
< No
< No
< No Invoke local native methods that return (jlong)
< No
< No
< No
< No Invoke local native methods that return (jdouble)
< No
< No
< No
< No IGNORE local native method registration. IGNORE local native method un-registration. Somebody goofed. There is an incomplete definition somewhere. Due to the invocation of native_verify_ordinal_definition() above, this condition should not be reached unless one of the NATIVE_TABLE_JLxxxxx_RETURNTYPE macros does not have all of the entries that it needs. Definition at line 1413 of file native.c. References EXIT_JVM_METHOD, exit_throw_exception(), and JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR. Referenced by object_run_method(), and opcode_run(). |
|
Associate class name string with its local native method interface connection.
< null-terminated string form of METHOD_CHAR_OPEN_PARM < null-terminated string form of METHOD_CHAR_VOID < null-terminated string form of METHOD_CHAR_OPEN_PARM < null-terminated string form of METHOD_CHAR_OPEN_PARM < null-terminated string form of METHOD_CHAR_VOID Definition at line 1266 of file native.c. Referenced by linkage_resolve_class(). |