This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
JNI and class references
- To: java at gcc dot gnu dot org
- Subject: JNI and class references
- From: mgd at swarm dot org (Marcus G. Daniels)
- Date: 25 Mar 2001 16:52:27 -0800
In jni.cc, I see there's a template for jobject wrap_value, but not
one for jclass. My experience with JNI is that a jclass returned
from a call like GetObjectClass is also a local reference.
Is it not appropriate to also have a wrap_value for jclass returns?
Specifically, like this:
template<>
static jclass
wrap_value (JNIEnv *env, jclass value)
{
return value == NULL ? value : (jclass) _Jv_JNI_NewLocalRef (env, (jobject) value);
}
(The motivation being that code that expects that jclasses will be local
refs will be calling DeleteLocalRef in some circumstances, which will
crash the runtime if there isn't one.)