javap -verbose 查看字节码

源码:

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;
}

转载于:https://my.oschina.net/wfire/blog/532485

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值