1 Reply Latest reply: Nov 15, 2011 11:11 AM by 803542 RSS

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

    803542
      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");

      Why??

      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.