From .java to .smali file
Ask: Why would you want to do that?
Answer: For learning how java language is represented in smali
$ javac Hello.java
$ dx --dex --output=Hello.dex Hello.class
$ baksmali Hello.dex
There'll be a directory out/ and a file in it Hello.smali
For example, the content of Hello.java
Answer: For learning how java language is represented in smali
$ javac Hello.java
$ dx --dex --output=Hello.dex Hello.class
$ baksmali Hello.dex
There'll be a directory out/ and a file in it Hello.smali
For example, the content of Hello.java
public class Hello {
public static void main(String [] args) {
System.out.println("Aa");
}
}
Then, the content of out/Hello.smali
.class public LHello;
.super Ljava/lang/Object;
.source "Hello.java"
# direct methods
.method public constructor <init>()V
.registers 1
.prologue
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static main([Ljava/lang/String;)V
.registers 3
.prologue
.line 3
sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
const-string v1, "Aa"
invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
.line 4
return-void
.end method
Note: The dx command was from Android SDK build tools, the version of dx and the version of Java must be compatible, or there'll be issues.
Comments
Post a Comment