[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] Bug in java_nio_VMDirectByteBuffer.c
From: |
Michael Koch |
Subject: |
Re: [cp-patches] Bug in java_nio_VMDirectByteBuffer.c |
Date: |
Wed, 16 Mar 2005 07:42:55 +0100 |
User-agent: |
mutt-ng 1.5.9-r176i (Debian) |
On Tue, Mar 15, 2005 at 10:25:50PM -0600, Archie Cobbs wrote:
> There is a bug in java_nio_VMDirectByteBuffer.c in the function
> Java_java_nio_VMDirectByteBuffer_init().
>
> This function sets "classRawData", which is a static variable of type
> jclass, from the result of calling (*env)->FindClass(), and then returns,
> and then other JNI functions try to use this variable from within different
> JNI invocations.
>
> This is broken because the local native reference that was created by
> (*env)->FindClass() goes away when Java_java_nio_VMDirectByteBuffer_init()
> returns (not to mention that it could be used from a different thread).
>
> The solution is to put a global native reference around "classRawData".
> This fixes the problem for me. I'll commit the attached patch unless
> there are issues.
>
> 2005-03-15 Archie Cobbs <address@hidden>
>
> * native/jni/java-nio/java_nio_VMDirectByteBuffer.c: use
> global native reference to wrap persistent jclass variable.
Thanks, Looks good. Can you point me to some explaining links on the web
for this? All I found via goolge was not very well explaining. I think
there are much more of these bugs in out JNI code and more in my
upcoming new code. Perhaps I can fix them before commiting new code when
I understand this more.
Michael
--
Java Trap: http://www.gnu.org/philosophy/java-trap.html