|
Re: Bug in java_nio_VMDirectByteBuffer.c: msg#00127java.classpath.patches
Michael Koch wrote: * native/jni/java-nio/java_nio_VMDirectByteBuffer.c: use Here's the JNI spec section talking about references: http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/design.html#wp16785 One thing that's not immediately obvious from the JNI spec, but is obvious once you read the details, is that a 'jclass' is the same as a 'jobject', except that it is assumed to refer to a java.lang.Class object. This is different from jfieldID and jmethodID which are "opaque" types [1]. Another common problem is using too many local native references, e.g., when creating and populating an array. You only get 16, and have to use DeleteLocalRef() to free up the ones you don't need anymore. By the way, my patch is not completely correct, because it never frees the global reference. The only way to properly do that would be to write a JNI_OnUnload() function and do it there. But in practice it will never matter because libjavanio is going to be loaded by the bootstrap class loader, which never gets unloaded. -Archie [1] Note that native code is responsible for maintaining a reference to the associated class, to avoid it from being unloaded, while using jfieldID and jmethodID variables: http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/design.html#wp17074 __________________________________________________________________________ Archie Cobbs * CTO, Awarix * http://www.awarix.com
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: FYI: boot library path update for VM integration guide, Mark Wielaard |
|---|---|
| Next by Date: | Re: Bug in java_nio_VMDirectByteBuffer.c, Archie Cobbs |
| Previous by Thread: | Re: Bug in java_nio_VMDirectByteBuffer.c, Michael Koch |
| Next by Thread: | Re: Bug in java_nio_VMDirectByteBuffer.c, Archie Cobbs |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |