title: jni native function overload signature
body: <p>I am trying to use function overload when declaring JNI native functions.</p>
  
  <p>The Java method is :</p>
  
  <pre><code>public native static void methodaaa(String type, int errorCode);
  public native static void methodaaa(String type, byte[] byts);
  </code></pre>
  
  <p>Without overload, the code is shown as below:</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_com_xxx_yyy_JavaCallCpp_methodaaa(JNIEnv* env, jobject thiz, jstring type, jint errorCode){}
  </code></pre>
  
  <p>And this works just fine.</p>
  
  <p>Then I tried to add overload :</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_com_xxx_yyy_JavaCallCpp_methodaaa(JNIEnv* env, jobject thiz, jstring type, jint errorCode){}
  
  JNIEXPORT void JNICALL Java_com_xxx_yyy_JavaCallCpp_methodaaa(JNIEnv* env, jobject thiz, jstring type, jbyteArray buffer){}
  </code></pre>
  
  <p>And this give me the error :</p>
  
  <pre><code>conflicting types for Java_com_xxx_yyy_JavaCallCpp_methodaaa
  </code></pre>
  
  <p>Then I did some research and it seems like I need to add a "__" to the end of the functions that I want to overload and also append the arguments Name mangling.</p>
  
  <p>So I tried:</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_com_xxx_yyy_JavaCallCpp_methodaaa__Ljava_lang_String_I(JNIEnv* env, jobject thiz, jstring type, jint errorCode){}
  
  JNIEXPORT void JNICALL Java_com_xxx_yyy_JavaCallCpp_methodaaa__Ljava_lang_String_B(JNIEnv* env, jobject thiz, jstring type, jbyteArray buffer){}
  </code></pre>
  
  <p>But it still not work, the error is :</p>
  
  <pre><code>No implementation found for native Lcom/xxx/yyy/JavaCallCpp;.methodaaa:(Ljava/lang/String;I)V
  </code></pre>
  
  <p>Is anybody know that how to write the JNICALL function name with a jstring as parameter or what I am doing wrong here?</p>
  
  <p>Any advice will be appreciated, thanks :)</p>
  
  <p>Update:</p>
  
  <p>I found the link here :</p>
  
  <p><a href="http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/design.html" rel="nofollow noreferrer">http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/design.html</a></p>
  
  <p>and then tried to modify my code :</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_com_xxx_yyy_JavaCallCpp_methodaaa__Ljava_lang_String_2I(JNIEnv* env, jobject thiz, jstring type, jint errorCode){}
  
  JNIEXPORT void JNICALL Java_com_xxx_yyy_JavaCallCpp_methodaaa__Ljava_lang_String_2B(JNIEnv* env, jobject thiz, jstring type, jbyteArray buffer){}
  </code></pre>
  
  <p>But, still I am getting the same error :</p>
  
  <pre><code>No implementation found for native Lcom/xxx/yyy/JavaCallCpp;.methodaaa:(Ljava/lang/String;I)V
  </code></pre>