java,dex 文件编译反编译

来源:互联网 发布:mac笔记本配置交换机 编辑:程序博客网 时间:2024/06/06 14:08
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 units00014c:                                        |[00014c] Test.<init>:()V00015c: 7010 0400 0000                         |0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0004000162: 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 units000164:                                        |[000164] Test.main:([Ljava/lang/String;)V000174: 2200 0100                              |0000: new-instance v0, LTest; // type@0001000178: 7010 0000 0000                         |0002: invoke-direct {v0}, LTest;.<init>:()V // method@000000017e: 6201 0000                              |0005: sget-object v1, Ljava/lang/System;.out:Ljava/io/PrintStream; // field@0000000182: 1232                                   |0007: const/4 v2, #int 3 // #3000184: 1243                                   |0008: const/4 v3, #int 4 // #4000186: 6e30 0100 2003                         |0009: invoke-virtual {v0, v2, v3}, LTest;.func:(II)I // method@000100018c: 0a00                                   |000c: move-result v000018e: 6e20 0300 0100                         |000d: invoke-virtual {v1, v0}, Ljava/io/PrintStream;.println:(I)V // method@0003000194: 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 units000198:                                        |[000198] Test.func:(II)I0001a8: 9000 0304                              |0000: add-int v0, v3, v40001ac: 9101 0304                              |0002: sub-int v1, v3, v40001b0: b210                                   |0004: mul-int/2addr v0, v10001b2: 0f00                                   |0005: return v0      catches       : (none)      positions     :         0x0000 line=4      locals        :         0x0000 - 0x0006 reg=2 this LTest;   source_file_idx   : 7 (Test.java)





0 0
原创粉丝点击