ChairmanC / dex2jar

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

Conversions between types sometimes missing in the resulting Java bytecode #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Have the dex code block below ( line 23 is of interest ) :

0    .registers 10

20 new-instance v2, Ljava/lang/StringBuilder;
21 const-string v3, ": was expecting closing \'"
22 invoke-direct {v2, v3}, 
Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
23 int-to-char v3, p3
24 invoke-virtual {v2, v3}, 
Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
25 move-result-object v2
26 const-string v3, "\' for name"
27 invoke-virtual {v2, v3}, 
Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
28 move-result-object v2
29 invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
30 move-result-object v2
31 invoke-virtual {p0, v2}, Lr;->c(Ljava/lang/String;)V

2. Convert it to jar using dex2jar. Resulting jar is missing the conversion 
from int to char in line 23. 

   55:  new #56; //class java/lang/StringBuilder
   58:  dup
   59:  ldc #58; //String : was expecting closing '
   61:  invokespecial   #61; //Method java/lang/StringBuilder."<init>":(Ljava/lang/String;)V
   64:  iload_3      //NO I2C  :(
   65:  invokevirtual   #65; //Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
   68:  ldc #67; //String ' for name
   70:  invokevirtual   #70; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   73:  invokevirtual   #74; //Method java/lang/StringBuilder.toString:()Ljava/lang/String;
   76:  invokevirtual   #77; //Method c:(Ljava/lang/String;)V

64:iload 3 loads the third argument (int) but does not convert it to char 
before invoke virtual.

3. Convert it back to dex. 

0    .registers 10

    new-instance v1, Ljava/lang/StringBuilder;
    const-string v3, ": was expecting closing \'"
    invoke-direct {v1, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
                                    //conversion missing
    invoke-virtual {v1, p3}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
    move-result-object v1
    const-string v3, "\' for name"
    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
    move-result-object v1
    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
    move-result-object v1
    invoke-virtual {p0, v1}, Lr;->c(Ljava/lang/String;)V

The int-to-char instruction is now missing so when I try to load the class the 
following verification error is given:

06-12 22:31:43.231: W/dalvikvm(446): VFY: register1 v9 type 12, wanted 11
06-12 22:31:43.231: W/dalvikvm(446): VFY:  rejecting opcode 0x6e at 0x002c
06-12 22:31:43.231: W/dalvikvm(446): VFY:  rejected Lr;.a 
(III)Ljava/lang/String;
06-12 22:31:43.231: W/dalvikvm(446): Verifier rejected class Lr;
06-12 22:31:43.241: D/AndroidRuntime(446): Shutting down VM

What version of the product are you using? On what operating system?

Latest build 0.0.9.x, OSX 10.6.8

I have attached the full methods if needed.

Original issue reported on code.google.com by O.Tsapo...@gmail.com on 12 Jun 2012 at 10:14

Attachments:

GoogleCodeExporter commented 9 years ago
Found jackson-all-1.9.6.jar and reproduce the problem, try to find why

Original comment by yyjdel...@gmail.com on 30 Jul 2012 at 12:46

GoogleCodeExporter commented 9 years ago
S2I, B2I, C2I, C2S can be auto convert without cast, which cause incorrect type 
merge in LocalType.

Original comment by yyjdel...@gmail.com on 30 Jul 2012 at 3:55

GoogleCodeExporter commented 9 years ago
This issue was closed by revision f2e47e07000b.

Original comment by yyjdel...@gmail.com on 3 Aug 2012 at 9:40