title: jni call java method which take a custom java interface as parameter
body: <p>I'm working on a plugin project on cocos2d-x platform , I'd like to write some c++ wrapper interface to invoke java method through <strong>JNI</strong> from <code>jar</code> SDK . I know how to use JNI to invoke a static java method, but I'm confused by the interface parameter in the java function.
  I hava a cpp function pointer to handling callbacks:</p>
  
  <pre><code>typedef void (* MyCallback)(int responseCode, string arg1, set&lt;string&gt; arg2);
  </code></pre>
  
  <p>and I want to write a cpp wrapper method like :</p>
  
  <pre><code>static void MyCpp::setTags(set&lt;string&gt; tags, MyCallback callback) //it use `JNI` to invoke java method setTags(Context context, Set&lt;String&gt; tags, TagCallback callback).
  </code></pre>
  
  <p>The java method I want to invoke in the wrapper is</p>
  
  <pre><code>public static void setTags(Context context, Set&lt;String&gt; tags, TagCallback callback)
  </code></pre>
  
  <p>and the <code>TagCallback</code> is an interface for API user to implement.
  So, is it possible to get <code>TagCallback</code> finally callback to <code>MyCallback</code> function? in other words , can I use <code>jni</code> to convert a cpp function pointer to java interface?
  Thanks for your patience .</p>
  
  <p><strong>EDIT:</strong>
  here is how to use <code>setTag</code> if user want to use java only:</p>
  
  <pre><code>public static void setTags(context, tags, new TagCallback{
      @Override
      public void callback(int arg0, String arg1, Set&lt;String&gt; arg2) {
              // TODO Auto-generated method stub
          }
  })
  </code></pre>
  
  <p>I'd like my SDK user to use my cpp wrapper method like this:</p>
  
  <pre><code>void setTagCallback(int responseCode, string arg1, set&lt;string&gt; arg2){
     //users handle callback themselves.
  }
  
  void someOtherMethodInvokeTheCppWrapperMethod(){
      MyCallback callback = setTagCallback;
      set&lt;string&gt; tags;
      MyCpp::setTags(tags,callback); 
  }
  </code></pre>