Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the internal identification of a Java method?

As we know, in Java, method name is not sufficient to distinguish different methods.

I think (may be wrong), to distinguish a method, it needs the following info:

(className, methodName, methodParameters)

Further,

  • how to identify a method more efficiently internally?
  • I heard of "method id". Does it mean there is a mapping between the above triple and an integer, so JVM use only method id after parsing?
  • If so, is it resided in symbol table?

Thanks!

like image 642
JackWM Avatar asked Jun 16 '12 03:06

JackWM


People also ask

What are the parts of a method in Java?

The only required elements of a method declaration are the method's return type, name, a pair of parentheses, () , and a body between braces, {} . More generally, method declarations have six components, in order: Modifiers—such as public , private , and others you will learn about later.

What is method declaration in Java?

Besides the name of the method, the method declaration carries information such as the return type of the method, the number and type of the arguments required by the method, and what other classes and objects can call the method.

What is the signature of a method Java?

The method signature in java is defined as the structure of the method that is designed by the programmer. The method signature is the combination of the method name and the parameter list. The method signature depicts the behavior of the method i.e types of values of the method, return type of the method, etc.

How do you get the method name inside the method?

Method Class | getName() Method in Java Method class is helpful to get the name of methods, as a String. To get name of all methods of a class, get all the methods of that class object. Then call getName() on those method objects. Return Value: It returns the name of the method, as String.


1 Answers

It's a CONSTANT_NameAndType_info Structure pointing at a method descriptor.

It pretty much consists of the method name, the parameter types, and (somewhat surprisingly) the return type.

like image 132
Laurence Gonsalves Avatar answered Sep 28 '22 00:09

Laurence Gonsalves