Java class文件中 StackMapTable Attribute如何解析?

private void ResolveStackMapTableAttribute()
{
    int number_of_entries=GetAndComputeTwoByte();
    System.out.println("ResolveStackMapTableAttribute. number_of_entries:" +number_of_entries);

    for (int i=0; i<number_of_entries; i++)
    {
        int type=GetByte();

        System.out.print("frame_type: "+type+ " ");
        if (type >=0 && type <=63)
        {
            System.out.println("frame_type: SAME");
        }
        else if (type >=64 && type <=127)
        {
            System.out.print("frame_type: SAME_LOCALS_1_STACK_ITEM ");
            VerificationTypeInfo();
        }
        else if (type ==247)
        {
            int offet_delta=GetAndComputeTwoByte();
            System.out.print("frame_type: SAME_LOCALS_1_STACK_ITEM_EXTENED. offet_delta"+offet_delta);
            VerificationTypeInfo();
        }
        else if (type >=248 && type <=250)
        {

            int offet_delta=GetAndComputeTwoByte();
            System.out.println("frame_type: CHOP, offet_delta: "+offet_delta);
        }
        else if (type == 251)
        {
            int offet_delta=GetAndComputeTwoByte();
            System.out.println("frame_type: SAME_FRAME_EXTENED, offet_delta: "+offet_delta);
        }
        else if (type >=252 && type <=254)
        {
            int offet_delta=GetAndComputeTwoByte();
            System.out.print("frame_type: APPEND, offet_delta: "+offet_delta);
            for(int j=0;j<type-251;j++)
            {
                VerificationTypeInfo();
            }
        }
        else if ( type == 255)
        {
            int offet_delta=GetAndComputeTwoByte();
            int number_of_locals=GetAndComputeTwoByte();
            System.out.print("frame_type: FULL_FRAME, offet_delta: "+offet_delta+" number_of_locals: "+number_of_locals);
            for(int j=0;j<number_of_locals;j++)
            {
                VerificationTypeInfo();
            }
            int number_of_stack_items=GetAndComputeTwoByte();
            for(int j=0;j<number_of_stack_items;j++)
            {
                VerificationTypeInfo();
            }
        }
    }

}
private void VerificationTypeInfo()
{
    int tag=GetByte();
    System.out.print("VerificationTypeInfo. tag: "+tag+" ");
    switch (tag)
    {
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:break;
        case 7:
        case 8:
            System.out.print("offset or cpool_index: "+Integer.toHexString(GetAndComputeTwoByte()));break;
        default:
            System.out.print("VerificationTypeInfo. switch default branch! tag: "+tag);
    }
    System.out.print("\n");
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值