Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "descriptor" and "signature"?

I am now using ASM (Java bytecode instrumentation library). To retrieve the signature of given method, there is a field which is named "desc". I guess this is an abbreviation of "descriptor", but why isn't it named as "signature"? Is there any difference between "descriptor" and "signature"?

like image 821
akry Avatar asked Sep 23 '11 08:09

akry


People also ask

What is a method descriptor?

A MethodDescriptor describes a particular method that a Java Bean supports for external access from other components.

What is Java method signature?

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.


1 Answers

In the context of asm, you care about internal names, method descriptors, type descriptors and signatures. Section numbers are from the asm doc.

2.1.2 Internal names

"The internal name of a class is just the fully qualified name of this class, where dots are replaced with slashes."

com/snark/Boojum

2.1.3 Type descriptors

[[Ljava/lang/Object;

2.1.4 Method descriptor

A method descriptor is a list of type descriptors that describe the parameter types and the return type of a method, in a single string.

int[] m(int i, String s) becomes (ILjava/lang/String;)[I

4.1. Generics (for signatures)

"For backward compatibility reasons the information about generic types is not stored in type or method descriptors (which were defined long before the introduction of generics in Java 5), but in similar constructs called type, method and class signatures."

This Java:

List<List<String>[]>

Becomes this signature:

Ljava/util/List<[Ljava/util/List<Ljava/lang/String;>;>;
like image 176
James Moore Avatar answered Sep 29 '22 11:09

James Moore