java - javap -v 中的 "Signature"是什么

标签 java maven

使用 javap -v,我得到如下输出:

Classfile /C:/temp/classcompare/PartnerRolle.class
  Last modified 09.12.2016; size 2880 bytes
  MD5 checksum 2deeeaa2734ac86f673bba871c05a997
  Compiled from "PartnerRolle.java"
public final class de.continentale.vs.common.model.enums.PartnerRolle extends java.lang.Enum<de.continentale.vs.common.model.enums.PartnerRolle>
  Signature: #110                         // Ljava/lang/Enum<Lde/continentale/vs/common/model/enums/PartnerRolle;>;
  SourceFile: "PartnerRolle.java"
  minor version: 0
  major version: 51
  flags: ACC_PUBLIC, ACC_FINAL, ACC_SUPER, ACC_ENUM

“签名 #110”是什么意思?

背景:当使用 Ant 和 Maven(相同的 Java 版本)编译时,我得到相同 java 源的不同类文件。我正在尝试找出原因。

最佳答案

javap -v 相当于 javap -verbose

类文件格式在 JVM 规范中定义。 如果你看一下 4.7.9. The signature attribute 部分你会发现Signature的定义

The Signature attribute is a fixed-length attribute in the attributes table of a ClassFile, field_info, or method_info structure. A Signature attribute records a signature for a class, interface, constructor, method, or field whose declaration in the Java programming language uses type variables or parameterized types. [...]

The Signature attribute has the following format:

Signature_attribute { u2 attribute_name_index; u4 attribute_length; u2 signature_index; }

The items of the Signature_attribute structure are as follows:

attribute_name_index

The value of the attribute_name_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info structure (§4.4.7) representing the string "Signature".

attribute_length

The value of the attribute_length item of a Signature_attribute structure must be two.

signature_index

The value of the signature_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info structure (§4.4.7) representing a class signature if this Signature attribute is an attribute of a ClassFile structure; a method signature if this Signature attribute is an attribute of a method_info structure; or a field signature otherwise.

Signature #110 表示您的签名存储在常量池表中的索引 110 处。

关于java - javap -v 中的 "Signature"是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41059979/

相关文章:

java - 在哪里可以找到 Tomcat-JDBC 池的公共(public) Maven 存储库?

java - 为什么 Maven 构建无法解析 Spring @Bean @Configuration 等注释?

java - 布局 xml 中自定义 View 的空指针异常

java - 循环不会自动运行

java - setOnClickListener() 不起作用

maven - 在Maven中运行Kotlintest

java - IN 中多个值的 jdbc preparedStatements

java - 将 jOOQ 与 Google Cloud SQL 结合使用

maven - 通过 maven 自动增加到新的 SNAPSHOT 版本

maven - 为什么Maven SCM插件需要connection/developerConnection?