|
Generated by JDiff |
||||||||
| PREV PACKAGE NEXT PACKAGE FRAMES NO FRAMES | |||||||||
This file contains all the changes in documentation in the packageorg.objectweb.asm.utilas colored differences. Deletions are shownlike this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.
ProvidesClass ASMifierClassVisitorsomeASMclassvisitors that can be useful for programming and debugging purposes. These class visitors are normally not used by applications at runtime. This is why they are bundled in an optional asm-util.jar library that is separated from (but requires) the asm.jar library, which contains the core ASM framework. @since ASM 1.3.2
AClass ASMifierClassVisitor, constructor ASMifierClassVisitor(PrintWriter)PrintClassVisitorClassVisitor that prints the ASM codethatthat generates the classesitit visits. This class visitor can be used toquicklyquickly write ASM code togenerategenerate some given bytecode:
- write the Java source code equivalent to
thethe bytecode you wanttoto generate;- compile it with javac;
- make a ASMifierClassVisitor visit this
compiledcompiled class (seethethe main method);- edit the generated source code,
ifif necessary.The source code printed when visitingthethe Hello class isthethe following:
where Hello is defined by:import org.objectweb.asm.*;import java.io.FileOutputStream;public classDumpHelloDump implementsConstantsOpcodes {publicstaticvoidmain(Stringpublic static byte[]argsdump() throws Exception { ClassWriter cw = new ClassWriter(false0);CodeVisitorFieldVisitor fv; MethodVisitor mv;cvAnnotationVisitor av0; cw.visit(49, ACC_PUBLIC + ACC_SUPER,""Hello"", null,""java/lang/Object"", null,);"cw.visitSource("Hello.java"", null); {cvmv = cw.visitMethod(ACC_PUBLIC+ ACC_STATIC,"main""<init>","([Ljava/lang/String"()V"", null, null);cv.visitFieldInsn(GETSTATIC,"java/lang/System","out","Ljava/io/PrintStream;");cvmv.visitLdcInsnvisitVarInsn("hello"ALOAD, 0);cvmv.visitMethodInsn(INVOKEVIRTUALINVOKESPECIAL,""java/iolang/PrintStream"Object","println""<init>","(Ljava/lang/String"()V"");cvmv.visitInsn(RETURN);cvmv.visitMaxs(21, 1); mv.visitEnd(); } {cvmv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC,"<quot;initmain>quot;",""([Ljava/lang/String;)V"", null, null);cvmv.visitVarInsnvisitFieldInsn(ALOADGETSTATIC,0"java/lang/System", "out", "Ljava/io/PrintStream;"); mv.visitLdcInsn("hello");cvmv.visitMethodInsn(INVOKESPECIALINVOKEVIRTUAL,""java/langio/Object"PrintStream","<quot;initprintln>quot;",""(Ljava/lang/String;)V"");cvmv.visitInsn(RETURN);cvmv.visitMaxs(12, 1);}cwmv.visitEnd();FileOutputStreamos=newFileOutputStream("Dumped.class");}os.write(cw.toByteArrayvisitEnd());osreturn cw.closetoByteArray(); } }
@author Ericpublic class Hello { public static void main(String[] args) { System.out.println(""hello""); } }Bruneton,Bruneton @author Eugene Kuleshov
Constructs a new ASMifierClassVisitor object.Class ASMifierClassVisitor, void main(String[])@param pw the print writer to be used to print the class.
Prints the ASM source code to generate the given class to the standard output.
Usage: ASMifierClassVisitor [-debug]<fullyqualifiedqualified class name or class file name>@param args the command line arguments.@throws Exception if the class cannot be found, or if an IO exception occurs.
A ClassAdapter that checks that its methods areClass CheckClassAdapter, constructor CheckClassAdapter(ClassVisitor)properlyproperly used.MoreMore precisely this class adapter checks each method call individually,basedbased only on its arguments, but does not checkthethe sequence of method calls. For example, the invalid sequence visitField(ACC_PUBLIC, "i", "I", null) visitField(ACC_PUBLIC, "i", "D", null) will not be detected by this class adapter. @author Eric Bruneton
Constructs a new CheckClassAdapterClass CheckClassAdapter, void main(String[])object.@param cv the class visitor to which this adapter must delegate calls.
Checks a given class.
Usage:CheckClassAdapterCheckClassAdapter <fullyqualifiedqualified class name or class file name>@param args the command line arguments.@throws Exception if the class cannot be found, or if an IO exception occurs.
AClass TraceClassVisitor, constructor TraceClassVisitor(ClassVisitor, PrintWriter)PrintClassVisitorClassVisitor that prints adisassembleddisassembled view of the classesitit visits. This class visitor can be used alone (seethethe main method) to disassemble a class. It can also be usedinin the middle ofclassclass visitor chain to trace the class that is visited ataa given point inthisthis chain. This may be uselful for debugging purposes.
The trace printedwhenwhen visiting the Hello class is the following:
where Hello is defined by://compiled from Helloclass version 49.java0 (49) // access flags 33 public class Hello { // compiledpublicfrom:staticHello.javamain([Ljava/lang/String;)Vaccess flags1GETSTATICjava/lang/SystemoutpublicLjava/io/PrintStream<init> ()VLDC"hello"ALOAD 0INVOKEVIRTUALINVOKESPECIAL java/iolang/PrintStreamObjectprintln<init> (Ljava/lang/String;)V RETURN MAXSTACK =21 MAXLOCALS = 1public//<init>access()Vflags 9 publicALOADstatic0main ([Ljava/lang/String;)VINVOKESPECIALGETSTATIC java/lang/ObjectSystem out Ljava/io/PrintStream; LDC <quot;inithello>quot; INVOKEVIRTUAL java/io/PrintStream println (Ljava/lang/String;)V RETURN MAXSTACK =12 MAXLOCALS =11 }
@author Ericpublic class Hello { public static void main(String[] args) { System.out.println(""hello""); } }Bruneton,Bruneton @author Eugene Kuleshov
Constructs a new TraceClassVisitorClass TraceClassVisitor, void main(String[])object.@param cv theclass visitorClassVisitor to which thisadapter mustvisitordelegatedelegates calls.MayMay be null. @param pw the print writer to be used to print the class.
Prints a disassembled view of the given class to the standard output.Class TraceClassVisitor, ClassVisitor cvUsage: TraceClassVisitor [-debug]
<fully qualified class name orclassclass file name >@param args the command line arguments.@throws Exception if the class cannot be found, or if an IO exception occurs.
The ClassVisitor to which this visitordelegatesdelegates calls. Maybebe null.