T
trekerj
Hi,
I'd like to introduce a tool named Jasml, which enables developers to
edit java class using java macro instructions. Jasml to Java is what
the assebling language to C. It can be downloaded at
http://jasml.sourceforge.net.
The example bellow will illustrate how Jasml works.
Supposing there's a simple class named Test, like:
--------------------- Test.java -------------------------
public class Test {
public static void main(String[] args){
System.out.println("Hello World!");
}
}
---------------------------------------------------------
You can decompile Test.class into Test.jasm, with it's content like:
--------------------Test.jasm----------------------------
[Major : 46]
[Minor : 0]
public class Test extends java.lang.Object{
public void <init> (){
line0 : aload_0
invokespecial void java.lang.Object.<init>()
line4 : return
[LocalVariables :
Test this start=line0, end=line4, index=0]
[MaxStack : 1]
[MaxLocal : 1]
}
public static void main (java.lang.String[]){
line0 : getstatic java.io.PrintStream java.lang.System.out
ldc "Halo world!"
invokevirtual void
java.io.PrintStream.println(java.lang.String)
line8 : return
[LocalVariables :
java.lang.String[] args start=line0, end=line8, index=0]
[MaxStack : 2]
[MaxLocal : 1]
}
[SourceFile : Test.java]
}
-----------------------------------------------------------
You can see that there are quite a lot more lines in the Test.jasm, but
this is the way JVM sees a class file.
Now, with the Test.jasm file at hand, you can do a lot of things, e.g.
making Test print out "Halo World!" instead of "Hello World!", or
adding another method.
Then you can compile the Test.jasm into Test.class again, and it will
work as you want.
As you can see in the example above, Jasml uses java like syntax for
class, method and field names. Indeed, most other similar tools dose
not have this feature: what is stored in .class file is just outputed
to the user, for example "[java/lang/String".
Jasml is very suitable to use when you want to change the
implementation of a class but without the source code or dependent
packages at hand, or if you want to check the inner impelentation of
specific class which you do not have the source and it can not be
decompiled properly.
At last, to use Jasml well, the knowledge of Java Virtual Machine
Specification is necessary. It can be downloaded at
http://java.sun.com/docs/books/vmspec/.
I'd like to introduce a tool named Jasml, which enables developers to
edit java class using java macro instructions. Jasml to Java is what
the assebling language to C. It can be downloaded at
http://jasml.sourceforge.net.
The example bellow will illustrate how Jasml works.
Supposing there's a simple class named Test, like:
--------------------- Test.java -------------------------
public class Test {
public static void main(String[] args){
System.out.println("Hello World!");
}
}
---------------------------------------------------------
You can decompile Test.class into Test.jasm, with it's content like:
--------------------Test.jasm----------------------------
[Major : 46]
[Minor : 0]
public class Test extends java.lang.Object{
public void <init> (){
line0 : aload_0
invokespecial void java.lang.Object.<init>()
line4 : return
[LocalVariables :
Test this start=line0, end=line4, index=0]
[MaxStack : 1]
[MaxLocal : 1]
}
public static void main (java.lang.String[]){
line0 : getstatic java.io.PrintStream java.lang.System.out
ldc "Halo world!"
invokevirtual void
java.io.PrintStream.println(java.lang.String)
line8 : return
[LocalVariables :
java.lang.String[] args start=line0, end=line8, index=0]
[MaxStack : 2]
[MaxLocal : 1]
}
[SourceFile : Test.java]
}
-----------------------------------------------------------
You can see that there are quite a lot more lines in the Test.jasm, but
this is the way JVM sees a class file.
Now, with the Test.jasm file at hand, you can do a lot of things, e.g.
making Test print out "Halo World!" instead of "Hello World!", or
adding another method.
Then you can compile the Test.jasm into Test.class again, and it will
work as you want.
As you can see in the example above, Jasml uses java like syntax for
class, method and field names. Indeed, most other similar tools dose
not have this feature: what is stored in .class file is just outputed
to the user, for example "[java/lang/String".
Jasml is very suitable to use when you want to change the
implementation of a class but without the source code or dependent
packages at hand, or if you want to check the inner impelentation of
specific class which you do not have the source and it can not be
decompiled properly.
At last, to use Jasml well, the knowledge of Java Virtual Machine
Specification is necessary. It can be downloaded at
http://java.sun.com/docs/books/vmspec/.