* src/vm/array.c (array_length_get): Removed IllegalArgumentException
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 20 Mar 2008 17:25:47 +0000 (18:25 +0100)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 20 Mar 2008 17:25:47 +0000 (18:25 +0100)
check for size.
* src/native/vm/sun/jvm.c (JVM_NewMultiArray): Explicitely check for
exceptions.

src/native/vm/sun/jvm.c
src/vm/array.c

index af73be21aad5e40939fa48ca83bc51dc2190b62b..5c8d361d5975446e6ddca1e700334c94217a0210 100644 (file)
@@ -2695,9 +2695,18 @@ jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim)
 
        length = array_length_get((java_handle_t *) ia);
 
-       if (length == 0)
+       /* We check here for exceptions thrown in array_length_get,
+          otherwise these exceptions get overwritten by the following
+          IllegalArgumentException. */
+
+       if (length < 0)
                return NULL;
 
+       if ((length <= 0) || (length > /* MAX_DIM */ 255)) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
        /* XXX This is just a quick hack to get it working. */
 
        dims = MNEW(long, length);
index b517b4e428b54309ffd2afaf49ddac94c7139a7f..f19177ac14e8aeb506f3aa0d409d10151b4b311b 100644 (file)
@@ -361,8 +361,8 @@ ARRAY_TYPEARRAY_ELEMENT_SET(double,  double)
        a ... Java array
 
    RETURN VALUE:
-        0 ... exception thrown
-          >0 ... length of the Java array
+         -1 ... exception thrown
+          >0 ... length of the Java array
 
 *******************************************************************************/
 
@@ -373,7 +373,7 @@ int32_t array_length_get(java_handle_t *a)
 
        if (a == NULL) {
                exceptions_throw_nullpointerexception();
-               return 0;
+               return -1;
        }
 
        LLNI_class_get(a, c);
@@ -381,16 +381,11 @@ int32_t array_length_get(java_handle_t *a)
        if (!class_is_array(c)) {
 /*             exceptions_throw_illegalargumentexception("Argument is not an array"); */
                exceptions_throw_illegalargumentexception();
-               return 0;
+               return -1;
        }
 
        size = LLNI_array_size(a);
 
-       if ((size <= 0) || (size > /* MAX_DIM */ 255)) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
        return size;
 }