RFR [XS] JDK-8039184: JNI Spec missing documentation on calling default methods

David Simms david.simms at oracle.com
Fri Apr 25 15:20:24 UTC 2014


JDK-8039184 <https://bugs.openjdk.java.net/browse/JDK-8039184>: JNI Spec 
missing documentation on calling default methods

Minor addition to the JNI Specification 
<http://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/jniTOC.html>:

Web review here: http://cr.openjdk.java.net/~dsimms/jnispec/8039184/ 
<http://cr.openjdk.java.net/%7Edsimms/jnispec/8039184/>

*Old Text*
	*New Text*


      GetMethodID

|jmethodID GetMethodID(JNIEnv *env, jclass clazz,
const char *name, const char *sig);|

Returns the method ID for an instance (nonstatic) method of a class or 
interface. The method may be defined in one of the|clazz|'s superclasses 
and inherited by|clazz|. The method is determined by its name and signature.

|GetMethodID()|causes an uninitialized class to be initialized.

To obtain the method ID of a constructor, supply|<init>|as the method 
name and|void|(|V|) as the return type.

	


      GetMethodID

|jmethodID GetMethodID(JNIEnv *env, jclass clazz,
const char *name, const char *sig);|

Returns the method ID for an instance (nonstatic) method of a class or 
interface. The method may be defined in one of the|clazz|'s supertypes 
and inherited by|clazz|. The method is determined by its name and signature.

|GetMethodID()|causes an uninitialized class to be initialized.

To obtain the method ID of a constructor, supply|<init>|as the method 
name and|void|(|V|) as the return type.


      CallNonvirtual<type>Method Routines, CallNonvirtual<type>MethodA
      Routines, CallNonvirtual<type>MethodV Routines

/NativeType//CallNonvirtual<type>Method/|(JNIEnv *env, jobject obj,
jclass clazz, jmethodID methodID, ...);|

/NativeType//CallNonvirtual<type>MethodA/|(JNIEnv *env, jobject obj,
jclass clazz, jmethodID methodID, const jvalue *args);|

/NativeType//CallNonvirtual<type>MethodV/|(JNIEnv *env, jobject obj,
jclass clazz, jmethodID methodID, va_list args);|

These families of operations invoke an instance (nonstatic) method on a 
Java object, according to the specified class and method ID. 
The|methodID|argument must be obtained by calling|GetMethodID||()|on the 
class|clazz|.

The/CallNonvirtual<type>Method/families of routines and 
the/Call<type>Method/families of routines are 
different./Call<type>Method/routines invoke the method based on the 
class of the object, while/CallNonvirtual<type>Method/routines invoke 
the method based on the class, designated by the|clazz|parameter, from 
which the method ID is obtained. The method ID must be obtained from the 
real class of the object or from one of its superclasses.

	


      CallNonvirtual<type>Method Routines, CallNonvirtual<type>MethodA
      Routines, CallNonvirtual<type>MethodV Routines

/NativeType//CallNonvirtual<type>Method/|(JNIEnv *env, jobject obj,
jclass clazz, jmethodID methodID, ...);|

/NativeType//CallNonvirtual<type>MethodA/|(JNIEnv *env, jobject obj,
jclass clazz, jmethodID methodID, const jvalue *args);|

/NativeType//CallNonvirtual<type>MethodV/|(JNIEnv *env, jobject obj,
jclass clazz, jmethodID methodID, va_list args);|

These families of operations invoke an instance (nonstatic) method on a 
Java object, according to the specified class and method ID. 
The|methodID|argument must be obtained by calling|GetMethodID||()|on the 
class|clazz|.

The/CallNonvirtual<type>Method/families of routines and 
the/Call<type>Method/families of routines are 
different./Call<type>Method/routines invoke the method based on the 
class or interface of the object, 
while/CallNonvirtual<type>Method/routines invoke the method based on the 
class, designated by the|clazz|parameter, from which the method ID is 
obtained. The method ID must be obtained from the real class of the 
object or from one of its supertypes.

/CallNonvirtual<type>Method/routines are the mechanism for 
invoking/"default interface methods"/introduced in Java 8.



More information about the hotspot-dev mailing list