method area constant pool

来源:互联网 发布:印刷报价小秘书软件 编辑:程序博客网 时间:2024/05/19 11:49
package com.cisco.learning;

字符串全部搞进去了! 基本类型只搞了final
public class ClassDemo {


final int finalInt = 1;
final Integer finalInteger = new Integer(2);
final static int finalStaticInt = 3;
int commonInt = 4;
static int staitcInt = 5;


final String finalString = "1";
final String finalStringObject = new String("2");
final static String finalStaticString = "3";
String commonString = "4";
static String staitcString = "5";


int testInt() {
final int finalInt_Method = 6;
int commonInt_Method = 7;


System.out.println(8);
System.out.println(new Integer(9));


return 10;
}


String testString() {
final String finalString = "6";
String commonString = "7";


System.out.println("8");
System.out.println(new String("9"));


return "10";
}

public static void main(String[] args) {
System.out.println("zhongguo");
}

/* Classfile /d:/ClassDemo.class
 Last modified 2012-2-14; size 1655 bytes
 MD5 checksum 9e6224b902b0a977a7429df2e642f1df
 Compiled from "ClassDemo.java"
public class com.cisco.learning.ClassDemo
 SourceFile: "ClassDemo.java"
 minor version: 0
 major version: 50
 flags: ACC_PUBLIC, ACC_SUPER


Constant pool:
   #1 = Class              #2            //  com/cisco/learning/ClassDemo
   #2 = Utf8               com/cisco/learning/ClassDemo
   #3 = Class              #4            //  java/lang/Object
   #4 = Utf8               java/lang/Object
   #5 = Utf8               finalInt
   #6 = Utf8               I
   #7 = Utf8               ConstantValue
   #8 = Integer            1
   #9 = Utf8               finalInteger
  #10 = Utf8               Ljava/lang/Integer;
  #11 = Utf8               finalStaticInt
  #12 = Integer            3
  #13 = Utf8               commonInt
  #14 = Utf8               staitcInt
  #15 = Utf8               finalString
  #16 = Utf8               Ljava/lang/String;
  #17 = String             #18           //  1
  #18 = Utf8               1
  #19 = Utf8               finalStringObject
  #20 = Utf8               finalStaticString
  #21 = String             #22           //  3
  #22 = Utf8               3
  #23 = Utf8               commonString
  #24 = Utf8               staitcString
  #25 = Utf8               <clinit>
  #26 = Utf8               ()V
  #27 = Utf8               Code
  #28 = Fieldref           #1.#29        //  com/cisco/learning/ClassDemo.staitcInt:I
  #29 = NameAndType        #14:#6        //  staitcInt:I
  #30 = String             #31           //  5
  #31 = Utf8               5
  #32 = Fieldref           #1.#33        //  com/cisco/learning/ClassDemo.staitcString:Ljava/lang/String;
  #33 = NameAndType        #24:#16       //  staitcString:Ljava/lang/String;
  #34 = Utf8               LineNumberTable
  #35 = Utf8               LocalVariableTable
  #36 = Utf8               <init>
  #37 = Methodref          #3.#38        //  java/lang/Object."<init>":()V
  #38 = NameAndType        #36:#26       //  "<init>":()V
  #39 = Fieldref           #1.#40        //  com/cisco/learning/ClassDemo.finalInt:I
  #40 = NameAndType        #5:#6         //  finalInt:I
  #41 = Class              #42           //  java/lang/Integer
  #42 = Utf8               java/lang/Integer
  #43 = Methodref          #41.#44       //  java/lang/Integer."<init>":(I)V
  #44 = NameAndType        #36:#45       //  "<init>":(I)V
  #45 = Utf8               (I)V
  #46 = Fieldref           #1.#47        //  com/cisco/learning/ClassDemo.finalInteger:Ljava/lang/Integer;
  #47 = NameAndType        #9:#10        //  finalInteger:Ljava/lang/Integer;
  #48 = Fieldref           #1.#49        //  com/cisco/learning/ClassDemo.commonInt:I
  #49 = NameAndType        #13:#6        //  commonInt:I
  #50 = Fieldref           #1.#51        //  com/cisco/learning/ClassDemo.finalString:Ljava/lang/String;
  #51 = NameAndType        #15:#16       //  finalString:Ljava/lang/String;
  #52 = Class              #53           //  java/lang/String
  #53 = Utf8               java/lang/String
  #54 = String             #55           //  2
  #55 = Utf8               2
  #56 = Methodref          #52.#57       //  java/lang/String."<init>":(Ljava/lang/String;)V
  #57 = NameAndType        #36:#58       //  "<init>":(Ljava/lang/String;)V
  #58 = Utf8               (Ljava/lang/String;)V
  #59 = Fieldref           #1.#60        //  com/cisco/learning/ClassDemo.finalStringObject:Ljava/lang/String;
  #60 = NameAndType        #19:#16       //  finalStringObject:Ljava/lang/String;
  #61 = String             #62           //  4
  #62 = Utf8               4
  #63 = Fieldref           #1.#64        //  com/cisco/learning/ClassDemo.commonString:Ljava/lang/String;
  #64 = NameAndType        #23:#16       //  commonString:Ljava/lang/String;
  #65 = Utf8               this
  #66 = Utf8               Lcom/cisco/learning/ClassDemo;
  #67 = Utf8               testInt
  #68 = Utf8               ()I
  #69 = Fieldref           #70.#72       //  java/lang/System.out:Ljava/io/PrintStream;
  #70 = Class              #71           //  java/lang/System
  #71 = Utf8               java/lang/System
  #72 = NameAndType        #73:#74       //  out:Ljava/io/PrintStream;
  #73 = Utf8               out
  #74 = Utf8               Ljava/io/PrintStream;
  #75 = Methodref          #76.#78       //  java/io/PrintStream.println:(I)V
  #76 = Class              #77           //  java/io/PrintStream
  #77 = Utf8               java/io/PrintStream
  #78 = NameAndType        #79:#45       //  println:(I)V
  #79 = Utf8               println
  #80 = Methodref          #76.#81       //  java/io/PrintStream.println:(Ljava/lang/Object;)V
  #81 = NameAndType        #79:#82       //  println:(Ljava/lang/Object;)V
  #82 = Utf8               (Ljava/lang/Object;)V
  #83 = Utf8               finalInt_Method
  #84 = Utf8               commonInt_Method
  #85 = Utf8               testString
  #86 = Utf8               ()Ljava/lang/String;
  #87 = String             #88           //  6
  #88 = Utf8               6
  #89 = String             #90           //  7
  #90 = Utf8               7
  #91 = String             #92           //  8
  #92 = Utf8               8
  #93 = Methodref          #76.#94       //  java/io/PrintStream.println:(Ljava/lang/String;)V
  #94 = NameAndType        #79:#58       //  println:(Ljava/lang/String;)V
  #95 = String             #96           //  9
  #96 = Utf8               9
  #97 = String             #98           //  10
  #98 = Utf8               10
  #99 = Utf8               main
 #100 = Utf8               ([Ljava/lang/String;)V
 #101 = String             #102          //  zhongguo
 #102 = Utf8               zhongguo
 #103 = Utf8               args
 #104 = Utf8               [Ljava/lang/String;
 #105 = Utf8               SourceFile
 #106 = Utf8               ClassDemo.java
{
 final int finalInt;
   flags: ACC_FINAL


   ConstantValue: int 1


 final java.lang.Integer finalInteger;
   flags: ACC_FINAL




 static final int finalStaticInt;
   flags: ACC_STATIC, ACC_FINAL


   ConstantValue: int 3


 int commonInt;
   flags: 




 static int staitcInt;
   flags: ACC_STATIC




 final java.lang.String finalString;
   flags: ACC_FINAL


   ConstantValue: String 1


 final java.lang.String finalStringObject;
   flags: ACC_FINAL




 static final java.lang.String finalStaticString;
   flags: ACC_STATIC, ACC_FINAL


   ConstantValue: String 3


 java.lang.String commonString;
   flags: 




 static java.lang.String staitcString;
   flags: ACC_STATIC




 static {};
   flags: ACC_STATIC


   Code:
     stack=1, locals=0, args_size=0
        0: iconst_5      
        1: putstatic     #28                 // Field staitcInt:I
        4: ldc           #30                 // String 5
        6: putstatic     #32                 // Field staitcString:Ljava/lang/String;
        9: return        
     LineNumberTable:
       line 9: 0
       line 15: 4
       line 3: 9
     LocalVariableTable:
       Start  Length  Slot  Name   Signature


 public com.cisco.learning.ClassDemo();
   flags: ACC_PUBLIC


   Code:
     stack=4, locals=1, args_size=1
        0: aload_0       
        1: invokespecial #37                 // Method java/lang/Object."<init>":()V
        4: aload_0       
        5: iconst_1      
        6: putfield      #39                 // Field finalInt:I
        9: aload_0       
       10: new           #41                 // class java/lang/Integer
       13: dup           
       14: iconst_2      
       15: invokespecial #43                 // Method java/lang/Integer."<init>":(I)V
       18: putfield      #46                 // Field finalInteger:Ljava/lang/Integer;
       21: aload_0       
       22: iconst_4      
       23: putfield      #48                 // Field commonInt:I
       26: aload_0       
       27: ldc           #17                 // String 1
       29: putfield      #50                 // Field finalString:Ljava/lang/String;
       32: aload_0       
       33: new           #52                 // class java/lang/String
       36: dup           
       37: ldc           #54                 // String 2
       39: invokespecial #56                 // Method java/lang/String."<init>":(Ljava/lang/String;)V
       42: putfield      #59                 // Field finalStringObject:Ljava/lang/String;
       45: aload_0       
       46: ldc           #61                 // String 4
       48: putfield      #63                 // Field commonString:Ljava/lang/String;
       51: return        
     LineNumberTable:
       line 3: 0
       line 5: 4
       line 6: 9
       line 8: 21
       line 11: 26
       line 12: 32
       line 14: 45
       line 3: 51
     LocalVariableTable:
       Start  Length  Slot  Name   Signature
              0      52     0  this   Lcom/cisco/learning/ClassDemo;


 int testInt();
   flags: 


   Code:
     stack=4, locals=3, args_size=1
        0: bipush        6
        2: istore_1      
        3: bipush        7
        5: istore_2      
        6: getstatic     #69                 // Field java/lang/System.out:Ljava/io/PrintStream;
        9: bipush        8
       11: invokevirtual #75                 // Method java/io/PrintStream.println:(I)V
       14: getstatic     #69                 // Field java/lang/System.out:Ljava/io/PrintStream;
       17: new           #41                 // class java/lang/Integer
       20: dup           
       21: bipush        9
       23: invokespecial #43                 // Method java/lang/Integer."<init>":(I)V
       26: invokevirtual #80                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
       29: bipush        10
       31: ireturn       
     LineNumberTable:
       line 18: 0
       line 19: 3
       line 21: 6
       line 22: 14
       line 24: 29
     LocalVariableTable:
       Start  Length  Slot  Name   Signature
              0      32     0  this   Lcom/cisco/learning/ClassDemo;
              3      29     1 finalInt_Method   I
              6      26     2 commonInt_Method   I


 java.lang.String testString();
   flags: 


   Code:
     stack=4, locals=3, args_size=1
        0: ldc           #87                 // String 6
        2: astore_1      
        3: ldc           #89                 // String 7
        5: astore_2      
        6: getstatic     #69                 // Field java/lang/System.out:Ljava/io/PrintStream;
        9: ldc           #91                 // String 8
       11: invokevirtual #93                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
       14: getstatic     #69                 // Field java/lang/System.out:Ljava/io/PrintStream;
       17: new           #52                 // class java/lang/String
       20: dup           
       21: ldc           #95                 // String 9
       23: invokespecial #56                 // Method java/lang/String."<init>":(Ljava/lang/String;)V
       26: invokevirtual #93                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
       29: ldc           #97                 // String 10
       31: areturn       
     LineNumberTable:
       line 28: 0
       line 29: 3
       line 31: 6
       line 32: 14
       line 34: 29
     LocalVariableTable:
       Start  Length  Slot  Name   Signature
              0      32     0  this   Lcom/cisco/learning/ClassDemo;
              3      29     1 finalString   Ljava/lang/String;
              6      26     2 commonString   Ljava/lang/String;


 public static void main(java.lang.String[]);
   flags: ACC_PUBLIC, ACC_STATIC


   Code:
     stack=2, locals=1, args_size=1
        0: getstatic     #69                 // Field java/lang/System.out:Ljava/io/PrintStream;
        3: ldc           #101                // String zhongguo
        5: invokevirtual #93                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
        8: return        
     LineNumberTable:
       line 38: 0
       line 39: 8
     LocalVariableTable:
       Start  Length  Slot  Name   Signature
              0       9     0  args   [Ljava/lang/String;
}
*/


}
原创粉丝点击