Skip to Main Content

Is a jclass object always a java.lang.Class object?

803542Nov 15 2011 — edited Nov 15 2011
In a native method, I'm receiving a jobjectArray called "args" as a parameter. I'm writing this:

jclass cls1 = env->GetObjectClass(args);
jmethodID mid1 = env->GetMethodID(cls1, "isArray", "()Z");

but this returns 0, indicating there is no isArray in the jclass returned by GetObjectClass. On the other hand, this works:

jclass cls2 = env->GetObjectClass(env->GetObjectClass(args));
jmethodID mid2 = env->GetMethodID(cls2, "isArray", "()Z");


When I call getMethods() (via JNI) on cls1, I get only the methods of java.lang.Object. When I do that on cls2 I get the methods of java.lang.Class.
Post Details
Added on Nov 15 2011
1 comment