title: How to call an a overridden super class method in Java through JNI?
body: <p>I'm attempting to override an activity callback method with a native implementation (to hook Lua into an activity). However I've hit a snag trying to call the superclass method within JNI code, as is required for the callback.</p>
  
  <p>For example, I have a class like this:</p>
  
  <pre><code>class TestActivity extends Activity {
  
      @Override
      protected native void onCreate(Bundle bundle);
  
      static {
          System.loadLibrary("test-jni")
      }
  }
  </code></pre>
  
  <p>And I'm trying to implement <code>TestActivity.onCreate()</code> in C it like this:</p>
  
  <pre><code>void Java_test_TestActivity_onCreate(JNIEnv* env, jobject obj, jobject bundle)
  {
      // Get class, super class, and super class method ID...
      jclass objcls = (*env)-&gt;GetObjectClass(env, obj);
      jclass sprcls = (*env)-&gt;GetSuperclass(env, objcls);
      jmethodID methid = (*env)-&gt;GetMethodID(env, sprcls, "onCreate", "(Landroid/os/Bundle;)V");
  
      // Call super class method...
      (*env)-&gt;CallVoidMethod(env, obj, methid, bundle);
  }
  </code></pre>
  
  <p>However, when I try this code, <code>TestActivity.onCreate()</code> is called within itself instead of <code>Activity.onCreate()</code>, Producing this error:</p>
  
  <p><code>JNI ERROR (app bug): local reference table overflow (max=512)</code></p>
  
  <p>I thought a jmethodID was specific to a class and would identify the super method, however this wasn't the case.</p>
  
  <p>So my question is, how do you implement this...</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle bundle) {
      super.onCreate(bundle);
  }
  </code></pre>
  
  <p>In JNI?</p>