循环语句
示例1:
:goto_0
invoke-interface {0}, Ljava/util/Iterator;->hasNext()Z
...
invoke-interface {0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
...
goto :goto_0
示例2:
.local v1, i:I # 初始化v1为0
:goto_0
if-lt v1, v5, :cond_0 # 如果v1小于v5,则跳转到cond_0处
...
:cond_0
invoke-interface {v0, v1}, Ljava/util/List;->get(I)Ljava/lang/Object;
...
add-int/lit8 v1, v1, 0x1 # 下一个索引
goto :goto_0
switch分支
示例1:
packed-switch p1, :pswitch_data_0
const-string v0, "she is a person" # default分支
:goto_0 # 所有case的出口
return-object v0 # 返回v0
:pswitch_0 # case 0
const-string v0, "she is a baby"
goto :goto_0
:pswitch_1 # case 1
const-string v0, "she is a girl"
goto :goto_0
nop
:pswitch_data_0
.packed-switch 0x0 # case区域,从0开始,依次递增
:pswitch_0 # case 0
:pswitch_1 # case 1
.end packed-switch
示例2:
sparse-switch p1, :sswitch_data_0 # sparse-switch分支, sswtich_data_0
const-string v0, "he is person" # default case
:goto_0 # case 出口
return-object v0
:sswtich_0 # case 5
const-string v0, "he is a baby"
goto :goto_0
:sswitch_1 # case 15
const-string v0, "he is girl"
goto :goto_0
nop
:sswtich_data_0
.sparse-switch
0x5 -> : sswtich_0
0xf -> : sswtich_1
.end sparse-switch
try-catch语句
示例:
:try_start_0 # 第一个try开始
invoke-static {p0}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I
:try_end_0 # 第一个try结束
.catch Ljava/lang/NumberFormatException;{:try_start_0 .. :try_end_0}:catch_1
:goto_0
return-void
:catch_1
move-exception v0
.local v0, e:Ljava/lang/NumberFormatException;
invoke-virtual {v0}, Ljava/lang/NumberFormatException;->printStackTrace()V
goto :goto_0