main.smali revision e24e70f9ad584d45d2a2af911c1d056163f1bc74
1.class public Lmain;
2
3.super Ljava/lang/Object;
4
5.method public static main([Ljava/lang/String;)V
6    .registers 3
7
8    :here4
9    const v0, 0
10
11    :here3
12
13    new-instance v2, Lsuperclass;
14    invoke-direct {v2}, Lsuperclass;-><init>()V
15
16    if-eqz v0, :here2
17
18
19    #this is the unresolvable instruction. v0 is always null,
20    #and this will always throw an exception. Everything below
21    #here, until the here2: label is dead code, and should be
22    #commented out. This instruction itself should be be replaced
23    #with a call to Ljava/lang/Object;->hashCode()I, followed
24    #by a goto/32 0, which is just there to prevent dexopt from
25    #thinking that execution will fall off the end of the method
26    #i.e. if all the code following this was dead (and thus commented
27    #out)
28    invoke-virtual {v0}, Lrandomclass;->getSuperclass()Lsuperclass;
29    move-result-object v1
30
31    
32    #a branch to outside the dead code. The branch label should not
33    #be commented out, because there is a non-dead instruction
34    #that branches to it
35    if-eqz v0, :here2
36
37    
38    #a branch to inside the dead code. the branch label should be
39    #commented out
40    if-eqz v0, :here
41
42    #another branch to outside the dead code. In this case, the "dead"
43    #instruction is the first instruction that references the label.
44    #the label should not be commented out, because it is referenced
45    #be a non-dead instruction
46    if-eqz v0, :here3
47
48    #one more branch to out the dead code. the branch label should be
49    #commented out, because there are no other non-dead instructions
50    #referenceding it
51    if-eqz v0, :here4
52
53    #another odexed instruction that uses the result of the
54    #first unresolveable odex instruction. this should
55    #appear as a commented invoke-virtual-quick instruction
56    invoke-virtual {v1}, Lsuperclass;->somemethod()V
57
58    :here
59
60    #a resolveable odex instruction in the dead code. It should be resolved,
61    #but still commented out
62    invoke-virtual {v2}, Lsuperclass;->somemethod()V
63
64    
65    :here2
66
67    #and we're back to the non-dead code
68    invoke-virtual {v2}, Lsuperclass;->somemethod()V
69
70    if-nez v0, :here3
71    
72
73    return-void
74.end method
75
76.method public static UnresolvedInstructionTest1()Lsuperclass;
77    .registers 2
78    const v0, 0
79
80    #this is an unresolvable instruction, due to v0 always being null
81    #this instruction should be replaced with "throw v0", followed by
82    #a "goto/32 0", since it would otherwise be the last instruction
83    #in the method, which isn't allowed
84    invoke-virtual/range {v0 .. v0}, Lrandomclass;->getSuperclass()Lsuperclass;
85
86    #the following instructions should be commented out
87    move-result-object v1
88    return-object v1
89.end method
90
91.method public static UnresolvedInstructionTest2()Lsuperclass;
92    .registers 2
93    const v0, 0
94
95    if-eqz v0, :here
96
97    #this is an unresolvable instruction, due to v0 always being null
98    #this instruction should be replaced with "throw v0". There shouldn't
99    #be a "goto/32 0" afterwards, since it won't be the last instruction
100    #in the method.
101    invoke-virtual/range {v0 .. v0}, Lrandomclass;->getSuperclass()Lsuperclass;
102
103    #the following instructions should be commented out
104    move-result-object v1
105    return-object v1
106
107    #and now back to our normal programming
108    :here
109    return-object v0
110.end method