Home » Android » java – GetStaticMethodId method signature for public static MyClass myMethod()

java – GetStaticMethodId method signature for public static MyClass myMethod()

Posted by: admin May 14, 2020 Leave a comment

Questions:

What is the method signature (for use with GetStaticMethodId) for this method:-

public static MyView newMyView() {
    return new MyView(RhodesService.getInstance().getContext(), null);
}

Is it "()Lcom/nativestuff/MyView;"? (if the package is com.nativestuff?)

How to&Answers:

Yes ()Lcom/nativestuff/MyView; is correct. In general:

  • B = byte
  • C = char
  • D = double
  • F = float
  • I = int
  • J = long
  • S = short
  • V = void
  • Z = boolean
  • Lfully-qualified-class = fully qualified class
  • [type = array of type
  • (argument types)return type = method type. If no arguments, use empty argument types: (). If return type is void (or constructor) use (argument types)V.

Answer:

()Lcom/nativestuff/MyView is correct.

You can also find the signature through

javap -s -classpath bin/classes com.nativestuff.MyView