From c5e99539727bcef4e19cca0f76a6c93d810684b4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 10 Apr 2003 17:32:45 +0000 Subject: [PATCH] Throw exception if Java array passed in is not the same size as the C array. Was using C free when array created with C++ new. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4672 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/java/arrays_java.i | 63 +++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/Lib/java/arrays_java.i b/Lib/java/arrays_java.i index 696dcab08..fedc8743c 100644 --- a/Lib/java/arrays_java.i +++ b/Lib/java/arrays_java.i @@ -1,7 +1,8 @@ /* arrays_java.i * These typemaps give more natural support for arrays. The typemaps are not efficient * as there is a lot of copying of the array values whenever the array is passed to C/C++ - * from Java and visa versa. + * from Java and visa versa. The Java array is expected to be the same size as the C array. + * An exception is thrown if they are not. Example usage: Wrapping: @@ -63,8 +64,7 @@ int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNI void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input) { int i; - jsize sz; - sz = JCALL1(GetArrayLength, jenv, input); + jsize sz = JCALL1(GetArrayLength, jenv, input); for (i=0; i