Is there a way to compute a Java class’s method’s signature? A signature
like ([Ljava/lang/String;)V represents a function that takes a String[] as argument
and returns void.
What’s the rule to compute the signature?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s always a set of parentheses enclosing type signifiers for the arguments, one after the other with no commas or anything, followed by a type signifier for the return value after the closing paren. It’s pretty straightforward.
Here’s a table of type signatures:
Those last two mean that to name a class, you say, for example,
Ljava/lang/Object;, and to name an array of (for example)int, you say[I, and an array of array ofintis[[I.If you wanted to literally compute the signature in Java code based on reflection, it’d be simple enough; just use the table above with rules for handling objects and arrays.