I have some native code, that in a single thread, loops over a Java method. To improve performance, I tried this:
static jclass clazz = env->FindClass("foo");
/*FIXME: GetStaticMethodID crashes with "Bad global or local reference"*/
jmethodID mid = env->GetStaticMethodID(clazz, "makeEvent", sig);
But with the static declaration of clazz, the JVM crashes on the
second iteration. Why? Is this really any different then using a C++ member field ?
My loop is really a bit more complicated then this, in that it starts several calls up. I hate the idea of
A) actually calling FindClass every iteration.
B) passing the clazz pointer through 3 layers of calls, just to avoid calling FindClass
Is there a better way?
Thanks!