pracio / dex2jar

Automatically exported from code.google.com/p/dex2jar
0 stars 0 forks source link

关于try-catch的指令优化 #113

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
/    0    0:aload_1         
    //    1    1:ifnull          8
    // try 4 8 handler(s) 9
    //    2    4:aload_1         
    //    3    5:invokevirtual   #237 <Method void HttpURLConnection.disconnect()>
    //    4    8:return          
    // catch Exception
    //    5    9:astore_2        
    //    6   10:aload_2         
    //    7   11:invokevirtual   #111 <Method void Exception.printStackTrace()>
    //    8   14:goto            8

优化成下面的jad就可以成功反编译了
    //    0    0:aload_1         
    //    1    1:ifnonnull       16
    // try 4 8 handler(s) 11
    //    2    4:aload_1         
    //    3    5:invokevirtual   #16  <Method void HttpURLConnection.disconnect()>
    //    4    8:goto            16
    // catch Exception
    //    5   11:astore_2        
    //    6   12:aload_2         
    //    7   13:invokevirtual   #21  <Method void Exception.printStackTrace()>
    //    8   16:return   

即由原来的
try
{somecode
}
L0:
somecode
return
catch
{somecode
}
goto L0
优化成
try
{somecode
}
goto L0
catch
{somecode
}

L0:
somecode
return
也就是说try和catch是连在一起,中间没有代码

Original issue reported on code.google.com by basheron...@gmail.com on 19 Mar 2012 at 6:47