源码:
package com.icnws;
public class Test12 {
private int m;
public int inc(){
return m+1;
}
}
编译成字节码之后,查看字节码 D:\workspace\jvm\out\production\jvm\com\icnws>javap -verbose Test12.class
Classfile /D:/workspace/jvm/out/production/jvm/com/icnws/Test12.class
Last modified 2015-8-2; size 364 bytes
MD5 checksum c06784dbb94a08b5a754ac0c4bf1c3ab
Compiled from "Test12.java"
public class com.icnws.Test12
SourceFile: "Test12.java"
minor version: 0
major version: 51
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Methodref #4.#18 // java/lang/Object."":()V
#2 = Fieldref #3.#19 // com/icnws/Test12.m:I
#3 = Class #20 // com/icnws/Test12
#4 = Class #21 // java/lang/Object
#5 = Utf8 m
#6 = Utf8 I
#7 = Utf8
#8 = Utf8 ()V
#9 = Utf8 Code
#10 = Utf8 LineNumberTable
#11 = Utf8 LocalVariableTable
#12 = Utf8 this
#13 = Utf8 Lcom/icnws/Test12;
#14 = Utf8 inc
#15 = Utf8 ()I
#16 = Utf8 SourceFile
#17 = Utf8 Test12.java
#18 = NameAndType #7:#8 // "":()V
#19 = NameAndType #5:#6 // m:I
#20 = Utf8 com/icnws/Test12
#21 = Utf8 java/lang/Object
{
public com.icnws.Test12();
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."
":()V
4: return
LineNumberTable:
line 2: 0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this Lcom/icnws/Test12;
public int inc();
flags: ACC_PUBLIC
Code:
stack=2, locals=1, args_size=1
0: aload_0
1: getfield #2 // Field m:I
4: iconst_1
5: iadd
6: ireturn
LineNumberTable:
line 5: 0
LocalVariableTable:
Start Length Slot Name Signature
0 7 0 this Lcom/icnws/Test12;
}