1、Signature属性:https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.9

2、ClassSignature、FieldTypeSignature、MethodTypeSignature说明:

https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.2-200

3、JLS:https://docs.oracle.com/javase/specs/index.html

举个例子,如下:

interface IA{}
interface IB{}

class CA{}

class TP extends CA implements IA,IB{}

class ParentClass<T>{}

interface ParentIA{}
interface ParentIB{}

// 出现在ClassFile的attributes属性中的Signature属性
// <T:Lcom/test18/CA;:Lcom/test18/IA;:Lcom/test18/IB;E:TT;>
// Lcom/test18/ParentClass<Ljava/lang/String;>;
// Lcom/test18/ParentIA;Lcom/test18/ParentIB;
public class TestClass<T extends CA&IA&IB,E extends T>
        extends ParentClass<String>
        implements ParentIA,ParentIB{

	// 出现在methods属性的attributes的Signature属性
	// <A:Lcom/test18/CA;:Lcom/test18/IA;:Lcom/test18/IB;B:TA;>
	// (TA;Ljava/util/List<+TB;>;)
	// V
    public <A extends CA&IA&IB,B extends A> void mymethod(A a,List<? extends B> list){

    	// 仅出现在常量池中,为什么?
    	// Ljava/util/List<Ljava/io/InputStream;>;
    	List<InputStream>  x = null;
    	// Ljava/util/List<-Ljava/io/InputStream;>;
    	List<? super InputStream> y = null;
    }
}

通过javap -verbose TestClass查看Class文件的结构:

Classfile /C:/TestClass.class
  Last modified 2018-7-5; size 1058 bytes
  MD5 checksum d9dc89733c2ea9a57bbced4b4c20f998
  Compiled from "TestClass.java"
public class com.test18.TestClass<T extends com.test18.CA & com.test18.IA & com.test18.IB, E extends T> extends com.test18.ParentClass<java.lang.String> implements com.test18.ParentIA, com.test18.ParentIB
  Signature: #29                          // <T:Lcom/test18/CA;:Lcom/test18/IA;:Lcom/test18/IB;E:TT;>Lcom/test18/ParentClass<Ljava/lang/String;>;Lcom/test18/ParentIA;Lcom/test18/ParentIB;
  SourceFile: "TestClass.java"
  minor version: 0
  major version: 51
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Methodref          #3.#32         //  com/test18/ParentClass."<init>":()V
   #2 = Class              #33            //  com/test18/TestClass
   #3 = Class              #34            //  com/test18/ParentClass
   #4 = Class              #35            //  com/test18/ParentIA
   #5 = Class              #36            //  com/test18/ParentIB
   #6 = Utf8               <init>
   #7 = Utf8               ()V
   #8 = Utf8               Code
   #9 = Utf8               LineNumberTable
  #10 = Utf8               LocalVariableTable
  #11 = Utf8               this
  #12 = Utf8               Lcom/test18/TestClass;
  #13 = Utf8               LocalVariableTypeTable
  #14 = Utf8               Lcom/test18/TestClass<TT;TE;>;
  #15 = Utf8               mymethod
  #16 = Utf8               (Lcom/test18/CA;Ljava/util/List;)V
  #17 = Utf8               a
  #18 = Utf8               Lcom/test18/CA;
  #19 = Utf8               list
  #20 = Utf8               Ljava/util/List;
  #21 = Utf8               x
  #22 = Utf8               y
  #23 = Utf8               TA;
  #24 = Utf8               Ljava/util/List<+TB;>;
  #25 = Utf8               Ljava/util/List<Ljava/io/InputStream;>;
  #26 = Utf8               Ljava/util/List<-Ljava/io/InputStream;>;
  #27 = Utf8               Signature
  #28 = Utf8               <A:Lcom/test18/CA;:Lcom/test18/IA;:Lcom/test18/IB;B:TA;>(TA;Ljava/util/List<+TB;>;)V
  #29 = Utf8               <T:Lcom/test18/CA;:Lcom/test18/IA;:Lcom/test18/IB;E:TT;>Lcom/test18/ParentClass<Ljava/lang/String;>;Lcom/test18/ParentIA;Lcom/test18/ParentIB;
  #30 = Utf8               SourceFile
  #31 = Utf8               TestClass.java
  #32 = NameAndType        #6:#7          //  "<init>":()V
  #33 = Utf8               com/test18/TestClass
  #34 = Utf8               com/test18/ParentClass
  #35 = Utf8               com/test18/ParentIA
  #36 = Utf8               com/test18/ParentIB
{
  public com.test18.TestClass();
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method com/test18/ParentClass."<init>":()V
         4: return
      LineNumberTable:
        line 53: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
               0       5     0  this   Lcom/test18/TestClass;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/test18/TestClass<TT;TE;>;

  public <A extends com/test18/CA & com/test18/IA & com/test18/IB, B extends A> void mymethod(A, java.util.List<? extends B>);
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=5, args_size=3
         0: aconst_null
         1: astore_3
         2: aconst_null
         3: astore        4
         5: return
      LineNumberTable:
        line 60: 0
        line 61: 2
        line 62: 5
      LocalVariableTable:
           Start  Length  Slot  Name   Signature
               0       6     0  this   Lcom/test18/TestClass;
               0       6     1     a   Lcom/test18/CA;
               0       6     2  list   Ljava/util/List;
               2       4     3     x   Ljava/util/List;
               5       1     4     y   Ljava/util/List;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/test18/TestClass<TT;TE;>;
            0       6     1     a   TA;
            0       6     2  list   Ljava/util/List<+TB;>;
            2       4     3     x   Ljava/util/List<Ljava/io/InputStream;>;
            5       1     4     y   Ljava/util/List<-Ljava/io/InputStream;>;

    Signature: #28                          // <A:Lcom/test18/CA;:Lcom/test18/IA;:Lcom/test18/IB;B:TA;>(TA;Ljava/util/List<+TB;>;)V
}

  

05-08 15:45