Gen代码解读

 

源代码为:

package com.test19;
public class Test04 {	
	void spin(){
		int i;
		for(i=0;i<100;i++){
			;
		}		
		i = 0;
	}
}

  

生成的class如下:

public class com.test19.Test04
  SourceFile: "Test04.java"
  minor version: 0
  major version: 51
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Methodref          #3.#17         //  java/lang/Object."<init>":()V
   #2 = Class              #18            //  com/test19/Test04
   #3 = Class              #19            //  java/lang/Object
   #4 = Utf8               <init>
   #5 = Utf8               ()V
   #6 = Utf8               Code
   #7 = Utf8               LineNumberTable
   #8 = Utf8               LocalVariableTable
   #9 = Utf8               this
  #10 = Utf8               Lcom/test19/Test04;
  #11 = Utf8               spin
  #12 = Utf8               i
  #13 = Utf8               I
  #14 = Utf8               StackMapTable
  #15 = Utf8               SourceFile
  #16 = Utf8               Test04.java
  #17 = NameAndType        #4:#5          //  "<init>":()V
  #18 = Utf8               com/test19/Test04
  #19 = Utf8               java/lang/Object
{
  public com.test19.Test04();
    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 2: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
               0       5     0  this   Lcom/test19/Test04;

  void spin();
    flags:
    Code:
      stack=2, locals=2, args_size=1
         0: iconst_0
         1: istore_1
         2: iload_1
         3: bipush        100
         5: if_icmpge     14
         8: iinc          1, 1
        11: goto          2
        14: iconst_0
        15: istore_1
        16: return
      LineNumberTable:
        line 5: 0
        line 9: 14
        line 10: 16
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
               0      17     0  this   Lcom/test19/Test04;
               2      15     1     i   I
      StackMapTable: number_of_entries = 2
           frame_type = 252 /* append */
             offset_delta = 2
        locals = [ int ]
           frame_type = 11 /* same */

}

  

Code编码为: 

03 3C 1B 10 64 A2 00 09 84 01 01 A7 FF F7 03 3C B1

opcode [03] - 0000: iconst_0
opcode [3C] - 0001: istore_1
opcode [1B] - 0002: iload_1
opcode [10] - 0003: bipush 100
opcode [A2] - 0005: if_icmpge 9
opcode [84] - 0008: iinc 1 1 ; index const
opcode [A7] - 0011: goto -9
opcode [03] - 0014: iconst_0
opcode [3C] - 0015: istore_1
opcode [B1] - 0016: return

 

3   60  27  16   100

-94 0   9   -124 1

1  -89 -1   -9   -79

 

转载于:https://www.cnblogs.com/extjs4/p/9393888.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值