This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

storing result of a Class getField call?


In some JNI code that works with Sun JDK 1.3 and Kaffe 1.0.6, I'm
stashing the results of a Class getField call in a variable and
globalrefing it.  By watching the unmark_for_gc call in jni.cc I can
see that the reference to the Field is not explicitly removed from the
JNI `ref_table', however, some time after caching the result of the
getField call (when I wish to use and reuse and reuse the stashed
Field), the object that is there has changed.  Often it no longer says
it is a java.lang.reflect.Field, but various other objects.  Or if it
is there, any use of it results in a crash.

I'm seeing this same behavior on Intel and Sparc.

Now, if I disable garbage collection, the problem doesn't occur.  Likewise,
if I do a lookup of the Field immediately adjacent to the use I wish
to make, it also works.

It seems fishy that this last workaround works as well as it does
if there is more general GC problem.  Any ideas?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]