java反编译jad,用JAD反编译Java-限制

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;

}

which is used as follows:

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.

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.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值