public void t(String d){
	final String str = "b";
	String s = "a"+"c"+str+d;
}

class文件反编译后内容如下:

public void t(String d) {
        String str = "b";
        (new StringBuilder()).append("acb").append(d).toString();
}

则被编译的class文件如下:  

public class com.test19.Test07
  SourceFile: "Test07.java"
  Utf8 1533966651178Utf8 1533966851637minor version: 0
  major version: 51
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Methodref          #9.#30         //  java/lang/Object."<init>":()V
   #2 = String             #31            //  b
   #3 = Class              #32            //  java/lang/StringBuilder
   #4 = Methodref          #3.#30         //  java/lang/StringBuilder."<init>":()V
   #5 = String             #33            //  acb
   #6 = Methodref          #3.#34         //  java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   #7 = Methodref          #3.#35         //  java/lang/StringBuilder.toString:()Ljava/lang/String;
   #8 = Class              #36            //  com/test19/Test07
   #9 = Class              #37            //  java/lang/Object
  #10 = Utf8               <init>
  #11 = Utf8               ()V
  #12 = Utf8               Code
  #13 = Utf8               LineNumberTable
  #14 = Utf8               CharacterRangeTable
  #15 = Utf8               LocalVariableTable
  #16 = Utf8               this
  #17 = Utf8               Lcom/test19/Test07;
  #18 = Utf8               t
  #19 = Utf8               (Ljava/lang/String;)V
  #20 = Utf8               d
  #21 = Utf8               Ljava/lang/String;
  #22 = Utf8               str
  #23 = Utf8               s
  #24 = Utf8               SourceFile
  #25 = Utf8               Test07.java
  #26 = Utf8               SourceID
  #27 = Utf8               1533966651178
  #28 = Utf8               CompilationID
  #29 = Utf8               1533966851637
  #30 = NameAndType        #10:#11        //  "<init>":()V
  #31 = Utf8               b
  #32 = Utf8               java/lang/StringBuilder
  #33 = Utf8               acb
  #34 = NameAndType        #38:#39        //  append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
  #35 = NameAndType        #40:#41        //  toString:()Ljava/lang/String;
  #36 = Utf8               com/test19/Test07
  #37 = Utf8               java/lang/Object
  #38 = Utf8               append
  #39 = Utf8               (Ljava/lang/String;)Ljava/lang/StringBuilder;
  #40 = Utf8               toString
  #41 = Utf8               ()Ljava/lang/String;
{
  public com.test19.Test07();
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>                                                      ":()V
         4: return
      LineNumberTable:
        line 34: 0
      CharacterRangeTable:
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
               0       5     0  this   Lcom/test19/Test07;

  public void t(java.lang.String);
    flags: ACC_PUBLIC
    Code:
      stack=2, locals=4, args_size=2
         0: ldc           #2                  // String b
         2: astore_2
         3: new           #3                  // class java/lang/StringBuilder

         6: dup
         7: invokespecial #4   // Method java/lang/StringBuilder."<init>":()V

        10: ldc           #5   // String acb
        12: invokevirtual #6   // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
        15: aload_1
        16: invokevirtual #6   // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
        19: invokevirtual #7   // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
        22: astore_3
        23: return
      LineNumberTable:
        line 63: 0
        line 64: 3
        line 65: 23
      CharacterRangeTable:
             0,  2,   fc10,   fc1a,    1        //  0,  2,   63:16,   63:26, sta                                                      tement
             3, 22,  1000a,  1001c,    1        //  3, 22,   64:10,   64:28, sta                                                      tement
             0, 23,   f819,  10402,    2        //  0, 23,   62:25,   65:02, blo                                                      ck
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
               0      24     0  this   Lcom/test19/Test07;
               0      24     1     d   Ljava/lang/String;
               3      21     2   str   Ljava/lang/String;
              23       1     3     s   Ljava/lang/String;
}

  

05-11 13:47