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"?
A MethodDescriptor describes a particular method that a Java Bean supports for external access from other components.
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.
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;>;>;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With