ASM + JASMIN combination for java class file editing in bytecode level
2010-12-12 20:27
489 查看
By using this combination, you will find that first we'll use ASM decompile the specified class and then rewite the specified class in JASMIN grammar, then compile this assemble source code file into java class file, first we'll show you the basic JASMIN grammar by a sample:
Typical Jasmin class source code:(HelloWorld case)
-------------------------------------------------------
.class public HelloWorld
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 2
.limit locals 1
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Hello World."
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
return
.end method
-------------------------------------------------------
If you want to get more knowledge for Jasmin, please see http://jasmin.sourceforge.net/instructions.html.
Use Asm to get assemble source code(command line set)
----------------------------------------------------------------------------
SET CP="E:/Resource/ASM/asm3.3lib/asm-3.3.jar;E:/Resource/ASM/asm3.3lib/asm-util-3.3.jar"
ATTENTION: DUE TO THERE IS A DIFFERENCE (IN GRAMMAR) BETWEEN ASM AND JASMIN, WE H***E TO REWRITE OR RE-ORGANIZE THE SOURCE AND COMPILE THEM AGAIN.
SET CP=%CP%;"E:/Resource/Test"
java -classpath %CP% org.objectweb.asm.util.TraceClassVisitor HelloWorld > HelloWorld.asm
----------------------------------------------------------------------------
Finally Run java class file in a source command:
----------------------------------------------------------------------------
SET CP="E:/Resource/Test"
java -cp %CP% examples.NewWorld
Use Jasmin to compile the specified assemble source code:
----------------------------------------------------------------------------
set CP=E:/Resource/Jasmin/jasmin-2.4/lib/ant.jar;
set CP=%CP%;E:/Resource/Jasmin/jasmin-2.4/lib/ant-launcher.jar;
set CP=%CP%;E:/Resource/Jasmin/jasmin-2.4/lib/java_cup.jar
java -cp %CP% -jar E:/Resource/Jasmin/jasmin-2.4/jasmin.jar examples/NewWorld.j
-----------------------------------------------------------------------
ATTENTION: DUE TO THERE IS A DIFFERENCE BETWEEN THE ASSEMBLE CODE DECOMPILED BY ASM AND THE SOURCE FOR JASMIN COMPILING, WE WILL H***E TO REWRITE OR RE-ORGANIZE THESE SOURCE.
Typical Jasmin class source code:(HelloWorld case)
-------------------------------------------------------
.class public HelloWorld
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 2
.limit locals 1
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Hello World."
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
return
.end method
-------------------------------------------------------
If you want to get more knowledge for Jasmin, please see http://jasmin.sourceforge.net/instructions.html.
Use Asm to get assemble source code(command line set)
----------------------------------------------------------------------------
SET CP="E:/Resource/ASM/asm3.3lib/asm-3.3.jar;E:/Resource/ASM/asm3.3lib/asm-util-3.3.jar"
ATTENTION: DUE TO THERE IS A DIFFERENCE (IN GRAMMAR) BETWEEN ASM AND JASMIN, WE H***E TO REWRITE OR RE-ORGANIZE THE SOURCE AND COMPILE THEM AGAIN.
SET CP=%CP%;"E:/Resource/Test"
java -classpath %CP% org.objectweb.asm.util.TraceClassVisitor HelloWorld > HelloWorld.asm
----------------------------------------------------------------------------
Finally Run java class file in a source command:
----------------------------------------------------------------------------
SET CP="E:/Resource/Test"
java -cp %CP% examples.NewWorld
Use Jasmin to compile the specified assemble source code:
----------------------------------------------------------------------------
set CP=E:/Resource/Jasmin/jasmin-2.4/lib/ant.jar;
set CP=%CP%;E:/Resource/Jasmin/jasmin-2.4/lib/ant-launcher.jar;
set CP=%CP%;E:/Resource/Jasmin/jasmin-2.4/lib/java_cup.jar
java -cp %CP% -jar E:/Resource/Jasmin/jasmin-2.4/jasmin.jar examples/NewWorld.j
-----------------------------------------------------------------------
ATTENTION: DUE TO THERE IS A DIFFERENCE BETWEEN THE ASSEMBLE CODE DECOMPILED BY ASM AND THE SOURCE FOR JASMIN COMPILING, WE WILL H***E TO REWRITE OR RE-ORGANIZE THESE SOURCE.
相关文章推荐
- Decompiled .class file,bytecode version:52.0(Java 8) Source for 'Android API 24 Platform' not found
- IntelliJ IDEA :decompiled.class file bytecode version:52.0(java 8) ,open source file.
- SpringBoot启动报错:Caused by: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
- Decompiled .class file,bytecode version:51.0(Java 7) Source for 'Android API 23 Platform' not found
- Decompiled .class file bytecode version:49.0(java5.0) load or open source file.
- @RequestParam注解使用:Name for argument type [java.lang.String] not available, and parameter name information not found in class file either.
- Mybatis问题-----There is no getter for property named 'productCode' in 'class java.lang.Strin g'
- IDEA下查看安卓源码踩坑:Decompiled.class file, bytecode version和Network shouldn't be accessed in EDT
- NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java class
- 异常备忘:java.lang.UnsupportedClassVersionError: Bad version number in .class file
- The parameters 'mainClass' for goal org.codeh aus.mojo:exec-maven-plugin:1.6.0:java are missing or
- There is no getter for property named 'userIds' in 'class java.lang.String'
- 初学java遇到的错误:Bad version nuber in .class file
- There is no getter for property named 'id' in 'class java.lang.Integer'问题解决办法
- Mybatis error,There is no getter for property named 'xx' in 'class java.lang.String',解决办法
- 深入了解Java ClassLoader、Bytecode 、ASM、cglib
- Java-出现The source attachment does not contain the source for the file xxx class
- Java Bad version number in .class file
- java.lang.ClassFormatError: Unknown constant tag 0 in class file【解决办法】
- Mybatis:ReflectionException: There is no getter for property named 'productName' in 'class java.lang