[kaffe] CVS kaffe (robilad): fix for reflection: creating Arrays of negative size should throw an exceptin

Kaffe CVS cvs-commits at kaffe.org
Tue Apr 18 15:20:14 PDT 2006


PatchSet 7244 
Date: 2006/04/18 22:11:00
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
fix for reflection: creating Arrays of negative size should throw an exceptin

2006-04-19  Dalibor Topic  <robilad at kaffe.org>

* libraries/clib/native/java_lang_reflect_VMArray.c
(Java_java_lang_reflect_VMArray_createObjectArray): Renamed to ...
(Java_java_lang_reflect_VMArray_createObjectArray0).

* libraries/javalib/vmspecific/java/lang/reflect/VMArray.java:
(createObjectArray) Check if dim is negative and throw
NegativeArraySizeException accordingly.
(createObjectArray0) New native method.

Members: 
	ChangeLog:1.4749->1.4750 
	libraries/clib/native/java_lang_reflect_VMArray.c:1.1->1.2 
	libraries/javalib/vmspecific/java/lang/reflect/VMArray.java:1.1->1.2 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4749 kaffe/ChangeLog:1.4750
--- kaffe/ChangeLog:1.4749	Tue Apr 18 20:58:58 2006
+++ kaffe/ChangeLog	Tue Apr 18 22:11:00 2006
@@ -1,3 +1,14 @@
+2006-04-19  Dalibor Topic  <robilad at kaffe.org>
+
+	* libraries/clib/native/java_lang_reflect_VMArray.c 
+	(Java_java_lang_reflect_VMArray_createObjectArray): Renamed to ...
+	(Java_java_lang_reflect_VMArray_createObjectArray0).
+
+	* libraries/javalib/vmspecific/java/lang/reflect/VMArray.java: 
+	(createObjectArray) Check if dim is negative and throw 
+	NegativeArraySizeException accordingly.
+	(createObjectArray0) New native method.
+	
 2006-04-18 Dalibor Topic  <robilad at kaffe.org>
 
 	* libraries/javalib/vmspecific/java/lang/reflect/Field.java
Index: kaffe/libraries/clib/native/java_lang_reflect_VMArray.c
diff -u kaffe/libraries/clib/native/java_lang_reflect_VMArray.c:1.1 kaffe/libraries/clib/native/java_lang_reflect_VMArray.c:1.2
--- kaffe/libraries/clib/native/java_lang_reflect_VMArray.c:1.1	Mon Apr  3 00:50:30 2006
+++ kaffe/libraries/clib/native/java_lang_reflect_VMArray.c	Tue Apr 18 22:11:06 2006
@@ -53,7 +53,7 @@
  * Signature: (Ljava/lang/Class;I)Ljava/lang/Object;
  */
 JNIEXPORT jobject JNICALL
-Java_java_lang_reflect_VMArray_createObjectArray
+Java_java_lang_reflect_VMArray_createObjectArray0
   (JNIEnv * env,
    jclass thisClass __attribute__ ((__unused__)),
    jclass arrayType, jint arrayLength)
Index: kaffe/libraries/javalib/vmspecific/java/lang/reflect/VMArray.java
diff -u kaffe/libraries/javalib/vmspecific/java/lang/reflect/VMArray.java:1.1 kaffe/libraries/javalib/vmspecific/java/lang/reflect/VMArray.java:1.2
--- kaffe/libraries/javalib/vmspecific/java/lang/reflect/VMArray.java:1.1	Mon Apr  3 00:51:36 2006
+++ kaffe/libraries/javalib/vmspecific/java/lang/reflect/VMArray.java	Tue Apr 18 22:11:06 2006
@@ -60,6 +60,15 @@
    * @throws NegativeArraySizeException if dim is negative
    * @throws OutOfMemoryError if memory allocation fails
    */
-  static native Object createObjectArray(Class type, int dim);
+  static Object createObjectArray(Class type, int dim)
+  {
+    if (dim < 0)
+      throw new NegativeArraySizeException("Can't create an array of " 
+					   + type.getName() 
+					   + " of length "
+					   + dim);
+    return createObjectArray0(type, dim);
+  }
 
+  static native Object createObjectArray0(Class type, int dim);
 }




More information about the kaffe mailing list