android 反编译后有很多goto语句该如何正确还原?
例如下面一段反编译后的代码:
public byte[] array()
{
ByteIO byteio;
Iterator iterator;
byteio = new ByteIO(size());
int i;
if(idList == null)
i = 0;
else
i = idList.size();
byteio.put((byte)i);
if(idList == null) goto _L2; else goto _L1
_L1:
iterator = idList.iterator();
_L5:
if(iterator.hasNext()) goto _L3; else goto _L2
_L2:
return byteio.array();
_L3:
byteio.putUint(((Long)iterator.next()).longValue());
if(true) goto _L5; else goto _L4
_L4:
}
说明:其实goto语句就是编译时代码的执行顺序,将if()else()等判断语句通过goto指示到对应的代码位置,如goto _L2就是跳到_L2行位置,最左侧的_L2:为行号。所以还原后的代码为:
public byte[] array(){
ByteIO byteio;
Iterator iterator;
byteio = new ByteIO(size());
int i;
if(idList == null)
i = 0;
else
i = idList.size();
byteio.put((byte)i);
if(idList == null){
return byteio.array();
}else{
iterator = idList.iterator();
while(iterator.hasNext()){
byteio.putUint(((Long)iterator.next()).longValue());
}
return byteio.array();
}
}