“描述符”和“描述符”有什么区别?和“签名”?
我现在使用 ASM(Java 字节码检测库)。要检索给定方法的签名,有一个名为“desc”的字段。我猜这是“描述符”的缩写,但为什么不将其命名为“签名”? “描述符”和“签名”有什么区别吗?
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"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 asm 的上下文中,您关心内部名称、方法描述符、类型描述符和签名。节号来自 asm 文档。
2.1.2 内部名称
“类的内部名称就是
此类的完全限定名称,其中点用斜杠替换。”
2.1.3 类型描述符
2.1.4 方法描述符
方法描述符是描述类型描述符的列表参数
类型和方法的返回类型位于单个字符串中。
4.1。泛型(用于签名)
“出于向后兼容性的原因,有关泛型类型的信息不
存储在类型或方法描述符中(在引入之前很久就定义了
Java 5 中的泛型),但在称为类型、方法的类似构造中
和类签名。”
这个 Java:
变成这个签名:
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."
2.1.3 Type descriptors
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.
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:
Becomes this signature:
查看 JVM 规范第 4.3.3 节,一方面,描述符包含返回类型 - 而这不是
但是......
(鉴于此,也不清楚描述符是否包含方法的名称...)
Looking at the JVM spec section 4.3.3, for one thing the descriptor contains the return type - whereas that isn't part of a the signature of a method.
but...
(Given this, it's also not clear that the descriptor contains the name of the method...)
“描述符”可能是指 JVM 规范§ 4.3.3。它描述了方法的参数类型和返回类型。它不包含方法名称。
“signatur”可能是指 Java 语言规范§ 8.4.2。它包含方法的名称以及参数类型。它不包含返回类型。
请注意,这两个术语是在两个不同的地方和不同的级别定义的。方法描述符存在于 JVM 级别,因此它与 Java 语言非常分离。然而,签名是一个非常相似的概念,但作用于 Java语言级别(如 JLS 中所定义)。
"descriptor" probably refers to the method descriptor as defined in the JVM spec § 4.3.3. It describes the parameter types and the return type of a method. It does not contain the method name.
"signatur" probably refers to the signature of as defined in the Java Language Specification § 8.4.2. It contains the name of the method as well as the parameter types. It does not contain the return type.
Note that those two terms are defined in two different places and at different levels. A method descriptor exists at the JVM-level, so it's pretty detached from the Java language. The signature, however is a very similar concept, but acts on the Java language level (as it's defined in the JLS).