[Proj] New proposal of JNI bindings for Proj.4

Martin Desruisseaux martin.desruisseaux at geomatys.fr
Mon Aug 29 11:04:13 EST 2011

Le 29/08/11 17:41, Eric Miller a écrit :
> But, what is the correct behavior if a pointer argument is null or an array 
> size is negative? Call abort()? Would that still crash the JVM? 

Calling exit() has been reported to stop the JVM (I didn't tested myself). I 
presume that it is the same for abort().

Inside a JNI function, if the arguments were provided by the user who invoked 
the function from the Java side, the correct behavior is to throw a Java 
exception (NullPointerException or IndexOutOfBoundsException). JNI functions 
have a JNIEnv argument which allows interaction with the JVM. So we can throw an 
exception from JNI code as below:

         jclass c = (*env)->FindClass(env, "java/lang/NullPointerException");
         if (c) (*env)->ThrowNew(env, c, "/Put some error message here./");
         return; // We need to exit from the C/C++ function.

Of course this apply only to JNI functions. The "normal" C library uses other 
mechanisms (typically no check - or if they check, an error code returned as an 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/proj/attachments/20110829/4e6256a8/attachment.htm 

More information about the Proj mailing list