[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JNI assertion failure

From: Dalibor Topic
Subject: Re: JNI assertion failure
Date: Sun, 24 Jul 2005 00:25:30 +0200
User-agent: Mozilla Thunderbird 1.0.2-6 (X11/20050513)

Archie Cobbs wrote:
Archie Cobbs wrote:

With Classpath 0.16, trying to run a very simple Swing demo under JCVM,
I get a JNI assertion failure in a call to GetIntField(), because the object
type and the fieldID are not compatible:

gnu/java/awt/peer/gtk/address@hidden not instance of gnu/java/awt/peer/gtk/GtkGenericPeer

Here is the relevant stack trace snippet:

#7 0x29f862d7 in Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (env=0x107ed6a0, obj=0x29795698, peer=0x2979569c)
    at gnu_java_awt_peer_gtk_GdkGraphics.c:154

Hmm, no response.. can anyone else confirm this problem??

It looks like this code is completely broken, because
it's trying to save a pointer in a field that doesn't
exist. Line 154 of gnu_java_awt_peer_gtk_GdkGraphics.c says:

  NSA_SET_PTR (env, obj, g)

but "obj" is a gnu/java/awt/peer/gtk/GdkGraphics object, not
a gnu/java/awt/peer/gtk/GtkGenericPeer object, the class that
contains the "native_state" field.

Since nobody seems to be listening, I'm going to check in the
attached patch. This will cause all programs that use the GTK
peer to crash with an assertion failure. Sorry! The code
is broken but I don't know how to fix it. At least now we get
an assertion failure instead of random memory corruption.

You have been warned :-)

Heh. ;)

+  assert ((*env)->IsAssignableFrom(env,
+    (*env)->GetObjectClass(env, obj), table->clazz));
   obj_id = (*env)->GetIntField (env, obj, table->hash);

Doesn't GetObjectClass change the state of env? If that's the case, it maybe shouldn't be an assert.

dalibor topic

reply via email to

[Prev in Thread] Current Thread [Next in Thread]