3

My java method contains a function

 public static void downLoadProfileImage(String url, String fileName,  int tag, int from)

I am getting a JNI signature error:

if (JniHelper::getStaticMethodInfo(jniMethodInfo, packageName.c_str(), "downLoadProfileImage", "(Ljava/lang/String;Ljava/lang/String;I;I;)V")) 

If I just keep the two strings, everything works. But with two integers it throws an error? What am I doing wrong?

2
  • 2
    Don't try to work these out by hand. Use 'javap -s'. It's never wrong.
    – user207421
    Mar 1, 2014 at 18:06
  • One thing you can do is look in the logs; there will be a message about the function not being found, along with the signature(s) it tried to match. Feb 2, 2022 at 21:39

1 Answer 1

13

The two integer markers (I) shouldn't have a following semicolon. Try:

(Ljava/lang/String;Ljava/lang/String;II)V

Edit: The best way to work is probably to use "javap -s" to have java print the signatures for you. Also make sure you read and understand this page

6
  • Thank you so much. Can you tell me when to and when not to use a ;
    – AndroidDev
    Feb 26, 2014 at 10:32
  • 3
    ; is an end marker used only in pair with L to mark the end of the class name.
    – Fredrik
    Feb 26, 2014 at 10:35
  • egrep helps with javap -s. For example: javap -s -public java.lang.String | egrep -A 2 "getBytes". On Windows, GOW provides egrep. Feb 27, 2014 at 0:26
  • 1
    Love the hint about using javap -s. Not sure why more people don't mention that. Thanks! You may want to provide an example and show that you point it to a .class file.
    – aardvarkk
    Nov 4, 2016 at 3:34
  • 1
    V stands for void. It’s easy to guess, but the link doesn’t mention V or void. Jun 22 at 14:09

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.