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);
a ... Java array
RETURN VALUE:
- 0 ... exception thrown
- >0 ... length of the Java array
+ -1 ... exception thrown
+ >= 0 ... length of the Java array
*******************************************************************************/
if (a == NULL) {
exceptions_throw_nullpointerexception();
- return 0;
+ return -1;
}
LLNI_class_get(a, c);
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;
}