Dalibor Topic wrote:
Doesn't GetObjectClass change the state of env? If that's the case, it maybe shouldn't be an assert.
Not sure what you mean.. but there is a bug: we need to delete the local native reference obtained by calling GetObjectClass. Attached is a better patch. Thanks, -Archie __________________________________________________________________________ Archie Cobbs * CTO, Awarix * http://www.awarix.com
Index: native/jni/classpath/native_state.c =================================================================== RCS file: /cvsroot/classpath/classpath/native/jni/classpath/native_state.c,v retrieving revision 1.11 diff -u -r1.11 native_state.c --- native/jni/classpath/native_state.c 14 Jul 2005 22:07:02 -0000 1.11 +++ native/jni/classpath/native_state.c 24 Jul 2005 22:38:39 -0000 @@ -36,6 +36,7 @@ exception statement from your version. */ #include <stdlib.h> +#include <assert.h> #include <jni.h> #include "native_state.h" @@ -165,6 +166,18 @@ *head = new_node; } +#ifndef NDEBUG +static void +cp_gtk_check_compat (JNIEnv * env, jobject obj, struct state_table *table) +{ + jclass objclazz; + + objclazz = (*env)->GetObjectClass(env, obj); + assert ((*env)->IsAssignableFrom(env, objclazz, table->clazz)); + (*env)->DeleteLocalRef(env, objclazz); +} +#endif + void cp_gtk_set_state_oid (JNIEnv * env, jobject lock, struct state_table *table, jint obj_id, void *state) @@ -214,6 +227,11 @@ cp_gtk_set_state (JNIEnv * env, jobject obj, struct state_table *table, void *state) { jint obj_id; + +#ifndef NDEBUG + cp_gtk_check_compat(env, obj, table); +#endif + obj_id = (*env)->GetIntField (env, obj, table->hash); if ((*env)->ExceptionOccurred (env) != NULL) @@ -227,6 +245,11 @@ cp_gtk_get_state (JNIEnv * env, jobject obj, struct state_table *table) { jint obj_id; + +#ifndef NDEBUG + cp_gtk_check_compat(env, obj, table); +#endif + obj_id = (*env)->GetIntField (env, obj, table->hash); if ((*env)->ExceptionOccurred (env) != NULL) @@ -239,6 +262,11 @@ cp_gtk_remove_state_slot (JNIEnv * env, jobject obj, struct state_table *table) { jint obj_id; + +#ifndef NDEBUG + cp_gtk_check_compat(env, obj, table); +#endif + obj_id = (*env)->GetIntField (env, obj, table->hash); if ((*env)->ExceptionOccurred (env) != NULL)
_______________________________________________ Classpath mailing list Classpath@gnu.org http://lists.gnu.org/mailman/listinfo/classpath