使用JAD反编译Java-限制 [英] Decompiling java with JAD - limitations

查看:197
本文介绍了使用JAD反编译Java-限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Java中的JAD来反编译几个jar文件(我也曾尝试过JD-GUI,但运气更低),但是我遇到了很多错误.一种类型(易于修复)似乎与内部类有关,但我也发现了这段代码:

I am trying to decompile a couple of jar files using JAD in Java (I tried JD-GUI as well with even less luck), but I get quite a lot of errors. One type (easy to fix) seems to be with internal classes, but I also found this bit of code:

static int[] $SWITCH_TABLE$atp$com$OrderType()
{
    $SWITCH_TABLE$atp$com$OrderType;
    if($SWITCH_TABLE$atp$com$OrderType == null) goto _L2; else goto _L1
_L1:
    return;
_L2:
    JVM INSTR pop ;
    int ai[] = new int[OrderType.values().length];
    try
    {
        ai[OrderType.LIMIT.ordinal()] = 2;
    }
    catch(NoSuchFieldError _ex) { }
    try
    {
        ai[OrderType.MARKET.ordinal()] = 1;
    }
    catch(NoSuchFieldError _ex) { }
    try
    {
        ai[OrderType.STOP.ordinal()] = 3;
    }
    catch(NoSuchFieldError _ex) { }
    try
    {
        ai[OrderType.TAKE.ordinal()] = 4;
    }
    catch(NoSuchFieldError _ex) { }
    return $SWITCH_TABLE$atp$com$OrderType = ai;
}

其用法如下:

switch($SWITCH_TABLE$atp$com$OrderType()[co.getOrderType().ordinal()])
        {
        case 1: // '\001'
            order = new Order(userID, null, co.getOrderType(), co.getOrderSide(), co.getOrderID(), co.getOrderSecurity(), co.getOrderQuantity(), broker);
            break;

        case 2: // '\002'
            order = new Order(userID, null, co.getOrderType(), co.getOrderSide(), co.getOrderPrice(), co.getOrderID(), co.getOrderSecurity(), co.getOrderQuantity(), broker);
            break;

        case 3: // '\003'
            order = new Order(userID, null, co.getOrderType(), co.getOrderSide(), co.getOrderPrice(), co.getOrderID(), co.getOrderSecurity(), co.getOrderQuantity(), broker);
            break;
        }

您知道这个结构最初可能是什么吗?

Any idea what this construct originally could have been?

推荐答案

我认为它是

I think it's tableswitch for an enum. It translates the arbitrary enum ordinal value to number 0..n, it allows improve performance of the switch statement.

更新 只是了解而已! 问题是-使用枚举的代码可以与枚举本身分开编译.因此,它在编译时不知道顺序值,因此无法构造适当的tableswitch op.因此,这就是为什么它引入了懒惰的SWITCH_TABLE结构来将当前可用的序数值映射到本地tableswitch int编号的原因.

UPDATE Just understood it! The problem is - the code which uses the enum could be compiled separately from the enum itself. So it doesn't know at compile time the ordinal values, so it cannot construct a proper tableswitch op. So, that's why it introduces the lazy SWITCH_TABLE structure to map currently available ordinal values to the local tableswitch int numbers.

这篇关于使用JAD反编译Java-限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆