jni getFields 'repeated allocation of very large block'
I try to get from a C++ program, with JNI, the list of fields of a
class, the goal being to get some reflection information on the C++
side, with this program:
int main( int argC, const char ** argV )
{
JavaVM *jvm;
JNIEnv *pEnv;
JavaVMInitArgs vm_args;
vm_args.version = JNI_VERSION_1_2;
vm_args.nOptions = 0;
vm_args.ignoreUnrecognized = true;
jint res = JNI_CreateJavaVM(&jvm, (void **)&pEnv, &vm_args);
jclass tstClass = pEnv->FindClass("MyClass");
jmethodID initId = pEnv->GetMethodID(tstClass,"<init>","()V");
jobject tstObjct = pEnv->NewObject(tstClass, initId );
jclass jlClss = pEnv->FindClass("java/lang/Class");
jmethodID getFlds = pEnv->GetMethodID(jlClss, "getFields", "()
[Ljava/lang/reflect/Field;");
/// 'Repeated allocation' starts from here...
jobjectArray fields = (jobjectArray)pEnv-
CallObjectMethod(tstObjct, getFlds);
...
jvm->DestroyJavaVM();
};
.... and this class :
class MyClass {
public String Nam = null;
public int Num = 0;
public MyClass() {
this("Alex", 123);
}
}
.... and I get this output after GetMethodId("getFields"):
GC Warning: Repeated allocation of very large block (appr. size
512000):
May lead to memory leak and poor performance.
GC Warning: Repeated allocation of very large block (appr. size
512000):
May lead to memory leak and poor performance.
.... etc ... (Endless)
I checked all returned values of JNI functions, they are fine.
gcj 4.2.2
gcc 4.2.2
Any idea, please ? Thanks.