[vtkusers] How does GetJavaArray() work?

Steve M. Robbins steven.robbins at videotron.ca
Mon Aug 29 13:38:45 EDT 2005


On Fri, Aug 26, 2005 at 03:34:21PM -0400, Steve M. Robbins wrote:

> The generated java class for vtkFloatArray contains:
> 
>   private native float[] GetJavaArray_0();
>   public float[] GetJavaArray()
>     { return GetJavaArray_0(); }
> 
> 
> Note that the native method is GetJavaArray_0.
> 
> The generated C++ JNI code contains:
> 
> extern "C" JNIEXPORT jarray JNICALL Java_vtk_vtkFloatArray_GetJavaArray_10(JNIEnv *env, jobject obj)
> { ... }
> 
> So the native function is really "GetJavaArray_10"!

The answer (thanks to David Marshburn for this) is simply that the "C"
method name for a native function uses an underscore to separate the
method name and path components.  If the method name contains an
underscore, it is translated to "_1".  

See http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/design.html#wp9502

-Steve



More information about the vtkusers mailing list