March 16, 2011 4 Comments
Look at this here:
$ java -jar target/daneel-0.0.1-SNAPSHOT-jar-with-dependencies.jar src/test/java/resources/HelloDroid.dex org.icedrobot.test.HelloDroid <init>()V 00000 HelloDroid : : ALOAD 0 00001 HelloDroid : HelloDroid : INVOKESPECIAL java/lang/Object. ()V 00002 HelloDroid : : RETURN main([Ljava/lang/StringV 00000 String . : : GETSTATIC java/lang/System.out : Ljava/io/PrintStream; 00001 String . : PrintStream : ASTORE 0 00002 PrintStream . : : LDC "Hello Android!" 00003 PrintStream . : String : ASTORE 1 00004 PrintStream String : : ALOAD 0 00005 PrintStream String : PrintStream : ALOAD 1 00006 PrintStream String : PrintStream String : INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/StringV 00007 PrintStream String : : RETURN
This is the first output from Daneel, as written by Remi Forax. It is running a HelloWorld implemented for Android, running on a Java VM. It’s using Smali for parsing the Dex file and ASM for writing Java bytecode. The Dex file is loaded through a special Java classloader that does all the translation.
The most awesome thing now is that Michael Starzinger at the same time proposed his own DaneelClassLoader, which is not using Smali, but instead our own Dex parser (mostly written by Michael). This thing can also run HelloWorld:
[michi@sheldon:scratch]$ java \ -Djava.system.class.loader=org.icedrobot.daneel.loader.DaneelClassLoader \ -Ddaneel.class.path=HelloDroid.dex \ HelloDroid Trying to find class 'HelloDroid' ... Hello Droid!
How cool is that??
I must add that Michael and Remi are doing an absolutely awesome job. They are driving forward at such a pace that I spend most of my time reading their patches, and have no chance to contribute anything myself. And if I do, you see what happens: they are doing it faster 🙂 Michael, Remi: you guys are absolutely AMAZING!