JAva,dexファイルコンパイル逆コンパイル
4867 ワード
class Test
{
int func(int a,int b){
return (a+b)*(a-b);
}
public static void main(String[]args){
Test test=new Test();
System.out.println(test.func(3,4));
}
}
Test.javaとして保存
.classファイルjavac Test.javaの生成
Javaバイトコードjavap Test.class>Testの生成
dxはbuild-toolsにあります
dexファイルdx--dex--output=Test.dex Test.classを生成
dexdumpはbuild-toolsにあります
dexdump -d Test.dex > Test_dex
JAVAバイトコード
Compiled from "Test.java"
class Test {
Test();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
int func(int, int);
Code:
0: iload_1
1: iload_2
2: iadd
3: iload_1
4: iload_2
5: isub
6: imul
7: ireturn
public static void main(java.lang.String[]);
Code:
0: new #2 // class Test
3: dup
4: invokespecial #3 // Method "<init>":()V
7: astore_1
8: getstatic #4 // Field java/lang/System.out:Ljava/io/PrintStream;
11: aload_1
12: iconst_3
13: iconst_4
14: invokevirtual #5 // Method func:(II)I
17: invokevirtual #6 // Method java/io/PrintStream.println:(I)V
20: return
}
dex
Processing 'Test.dex'...
Opened 'Test.dex', DEX version '035'
Class #0 -
Class descriptor : 'LTest;'
Access flags : 0x0000 ()
Superclass : 'Ljava/lang/Object;'
Interfaces -
Static fields -
Instance fields -
Direct methods -
#0 : (in LTest;)
name : '<init>'
type : '()V'
access : 0x10000 (CONSTRUCTOR)
code -
registers : 1
ins : 1
outs : 1
insns size : 4 16-bit code units
00014c: |[00014c] Test.<init>:()V
00015c: 7010 0400 0000 |0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0004
000162: 0e00 |0003: return-void
catches : (none)
positions :
0x0000 line=1
locals :
0x0000 - 0x0004 reg=0 this LTest;
#1 : (in LTest;)
name : 'main'
type : '([Ljava/lang/String;)V'
access : 0x0009 (PUBLIC STATIC)
code -
registers : 5
ins : 1
outs : 3
insns size : 17 16-bit code units
000164: |[000164] Test.main:([Ljava/lang/String;)V
000174: 2200 0100 |0000: new-instance v0, LTest; // type@0001
000178: 7010 0000 0000 |0002: invoke-direct {v0}, LTest;.<init>:()V // method@0000
00017e: 6201 0000 |0005: sget-object v1, Ljava/lang/System;.out:Ljava/io/PrintStream; // field@0000
000182: 1232 |0007: const/4 v2, #int 3 // #3
000184: 1243 |0008: const/4 v3, #int 4 // #4
000186: 6e30 0100 2003 |0009: invoke-virtual {v0, v2, v3}, LTest;.func:(II)I // method@0001
00018c: 0a00 |000c: move-result v0
00018e: 6e20 0300 0100 |000d: invoke-virtual {v1, v0}, Ljava/io/PrintStream;.println:(I)V // method@0003
000194: 0e00 |0010: return-void
catches : (none)
positions :
0x0000 line=8
0x0005 line=9
0x0010 line=10
locals :
Virtual methods -
#0 : (in LTest;)
name : 'func'
type : '(II)I'
access : 0x0000 ()
code -
registers : 5
ins : 3
outs : 0
insns size : 6 16-bit code units
000198: |[000198] Test.func:(II)I
0001a8: 9000 0304 |0000: add-int v0, v3, v4
0001ac: 9101 0304 |0002: sub-int v1, v3, v4
0001b0: b210 |0004: mul-int/2addr v0, v1
0001b2: 0f00 |0005: return v0
catches : (none)
positions :
0x0000 line=4
locals :
0x0000 - 0x0006 reg=2 this LTest;
source_file_idx : 7 (Test.java)