[kaffe] CVS kaffe (robilad): Improved ArrayStoreException error message
Kaffe CVS
cvs-commits at kaffe.org
Sun Nov 14 05:56:04 PST 2004
PatchSet 5455
Date: 2004/11/14 13:52:03
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Improved ArrayStoreException error message
2004-11-13 Mark Wielaard <mark at klomp.org>
* include/errors.h
(ArrayStoreException): Define to take a message.
* kaffe/kaffevm/soft.c
(soft_checkarraystore): Add message to ArrayStoreException.
* libraries/clib/native/System.c
(java_lang_System_arraycopy): Likewise.
Members:
ChangeLog:1.3001->1.3002
include/errors.h:1.14->1.15
kaffe/kaffevm/soft.c:1.67->1.68
libraries/clib/native/System.c:1.59->1.60
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3001 kaffe/ChangeLog:1.3002
--- kaffe/ChangeLog:1.3001 Sun Nov 14 01:10:07 2004
+++ kaffe/ChangeLog Sun Nov 14 13:52:03 2004
@@ -1,3 +1,12 @@
+2004-11-13 Mark Wielaard <mark at klomp.org>
+
+ * include/errors.h
+ (ArrayStoreException): Define to take a message.
+ * kaffe/kaffevm/soft.c
+ (soft_checkarraystore): Add message to ArrayStoreException.
+ * libraries/clib/native/System.c
+ (java_lang_System_arraycopy): Likewise.
+
2004-11-13 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java,
Index: kaffe/include/errors.h
diff -u kaffe/include/errors.h:1.14 kaffe/include/errors.h:1.15
--- kaffe/include/errors.h:1.14 Sun Oct 31 14:35:32 2004
+++ kaffe/include/errors.h Sun Nov 14 13:52:05 2004
@@ -101,7 +101,7 @@
#define IllegalMonitorStateException NEW_LANG_EXCEPTION(IllegalMonitorStateException)
#define NullPointerException NEW_LANG_EXCEPTION(NullPointerException)
#define ArrayIndexOutOfBoundsException NEW_LANG_EXCEPTION(ArrayIndexOutOfBoundsException)
-#define ArrayStoreException NEW_LANG_EXCEPTION(ArrayStoreException)
+#define ArrayStoreException(M) NEW_LANG_EXCEPTION_MESSAGE(ArrayStoreException, M)
#define ArithmeticException NEW_LANG_EXCEPTION(ArithmeticException)
#define AbstractMethodError(M) NEW_LANG_EXCEPTION_MESSAGE(AbstractMethodError, M)
#define ThreadDeath NEW_LANG_EXCEPTION(ThreadDeath)
Index: kaffe/kaffe/kaffevm/soft.c
diff -u kaffe/kaffe/kaffevm/soft.c:1.67 kaffe/kaffe/kaffevm/soft.c:1.68
--- kaffe/kaffe/kaffevm/soft.c:1.67 Sat Nov 6 20:02:07 2004
+++ kaffe/kaffe/kaffevm/soft.c Sun Nov 14 13:52:06 2004
@@ -584,7 +584,16 @@
soft_checkarraystore(Hjava_lang_Object* array, Hjava_lang_Object* obj)
{
if (obj != 0 && soft_instanceof(CLASS_ELEMENT_TYPE(OBJECT_CLASS(array)), obj) == 0) {
- throwException(ArrayStoreException);
+ Hjava_lang_Throwable* asexc;
+ const char* f = "can't store `%s' in `%s'";
+ const char *otype = CLASS_CNAME(OBJECT_CLASS(obj));
+ const char *atype = CLASS_CNAME(OBJECT_CLASS(array));
+ char *b;
+ b = checkPtr(KMALLOC(strlen(otype)+strlen(atype)+strlen(f)));
+ sprintf(b, f, otype, atype);
+ asexc = ArrayStoreException(b);
+ KFREE(b);
+ throwException(asexc);
}
}
Index: kaffe/libraries/clib/native/System.c
diff -u kaffe/libraries/clib/native/System.c:1.59 kaffe/libraries/clib/native/System.c:1.60
--- kaffe/libraries/clib/native/System.c:1.59 Thu Oct 14 11:12:10 2004
+++ kaffe/libraries/clib/native/System.c Sun Nov 14 13:52:06 2004
@@ -519,8 +519,28 @@
dclass = OBJECT_CLASS(dst);
/* Must be arrays */
- if (!CLASS_IS_ARRAY(sclass) || !CLASS_IS_ARRAY(dclass)) {
- throwException (ArrayStoreException);
+ if (!CLASS_IS_ARRAY(sclass)) {
+ Hjava_lang_Throwable* asexc;
+ const char* f = "source not an array `%s'";
+ const char *type = CLASS_CNAME(sclass);
+ char *b;
+ b = checkPtr(KMALLOC(strlen(type)+strlen(f)));
+ sprintf(b, f, type);
+ asexc = ArrayStoreException(b);
+ KFREE(b);
+ throwException(asexc);
+ }
+
+ if(!CLASS_IS_ARRAY(dclass)) {
+ Hjava_lang_Throwable* asexc;
+ const char* f = "destination not an array `%s'";
+ const char *type = CLASS_CNAME(dclass);
+ char *b;
+ b = checkPtr(KMALLOC(strlen(type)+strlen(f)));
+ sprintf(b, f, type);
+ asexc = ArrayStoreException(b);
+ KFREE(b);
+ throwException(asexc);
}
/* Make sure we'll keep in the array boundaries */
@@ -567,13 +587,31 @@
#endif
} else {
if (CLASS_IS_PRIMITIVE(sclass) || CLASS_IS_PRIMITIVE(dclass)) {
- throwException (ArrayStoreException);
+ Hjava_lang_Throwable* asexc;
+ const char* f = "incompatible array types `%s' and `%s'";
+ const char *stype = CLASS_CNAME(sclass);
+ const char *dtype = CLASS_CNAME(dclass);
+ char *b;
+ b = checkPtr(KMALLOC(strlen(stype)+strlen(dtype)+strlen(f)));
+ sprintf(b, f, stype, dtype);
+ asexc = ArrayStoreException(b);
+ KFREE(b);
+ throwException(asexc);
}
for (; len > 0; len -= sizeof(Hjava_lang_Object*)) {
Hjava_lang_Object* val = *(Hjava_lang_Object**)in;
if (val != 0 && !instanceof(dclass, OBJECT_CLASS(val))) {
- throwException (ArrayStoreException);
+ Hjava_lang_Throwable* asexc;
+ const char* f = "can't store `%s' in array of type `%s'";
+ const char *vtype = CLASS_CNAME(OBJECT_CLASS(val));
+ const char *atype = CLASS_CNAME(dclass);
+ char *b;
+ b = checkPtr(KMALLOC(strlen(vtype)+strlen(atype)+strlen(f)));
+ sprintf(b, f, vtype, atype);
+ asexc = ArrayStoreException(b);
+ KFREE(b);
+ throwException(asexc);
}
*(Hjava_lang_Object**)out = val;
in += sizeof(Hjava_lang_Object*);
More information about the kaffe
mailing list