asm-1.5.3/archive/ 40755 0 0 0 10146413674 10761 5ustar 0 0 asm-1.5.3/doc/ 40755 0 0 0 10146413676 10107 5ustar 0 0 asm-1.5.3/examples/ 40755 0 0 0 10146413675 11157 5ustar 0 0 asm-1.5.3/examples/adapt/ 40755 0 0 0 10146413675 12250 5ustar 0 0 asm-1.5.3/examples/adapt/etc/ 40755 0 0 0 10146413675 13023 5ustar 0 0 asm-1.5.3/examples/adapt/src/ 40755 0 0 0 10146413675 13037 5ustar 0 0 asm-1.5.3/examples/analysis/ 40755 0 0 0 10146413675 13002 5ustar 0 0 asm-1.5.3/examples/analysis/etc/ 40755 0 0 0 10146413675 13555 5ustar 0 0 asm-1.5.3/examples/analysis/src/ 40755 0 0 0 10146413675 13571 5ustar 0 0 asm-1.5.3/examples/annotations/ 40755 0 0 0 10146413675 13514 5ustar 0 0 asm-1.5.3/examples/annotations/src15/ 40755 0 0 0 10146413675 14451 5ustar 0 0 asm-1.5.3/examples/annotations/src15/annotations/ 40755 0 0 0 10146413675 17006 5ustar 0 0 asm-1.5.3/examples/attributes/ 40755 0 0 0 10146413675 13345 5ustar 0 0 asm-1.5.3/examples/attributes/etc/ 40755 0 0 0 10146413675 14120 5ustar 0 0 asm-1.5.3/examples/attributes/src/ 40755 0 0 0 10146413675 14134 5ustar 0 0 asm-1.5.3/examples/common/ 40755 0 0 0 10146413675 12447 5ustar 0 0 asm-1.5.3/examples/common/etc/ 40755 0 0 0 10146413675 13222 5ustar 0 0 asm-1.5.3/examples/compile/ 40755 0 0 0 10146413675 12607 5ustar 0 0 asm-1.5.3/examples/compile/etc/ 40755 0 0 0 10146413676 13363 5ustar 0 0 asm-1.5.3/examples/compile/src/ 40755 0 0 0 10146413675 13376 5ustar 0 0 asm-1.5.3/examples/helloworld/ 40755 0 0 0 10146413675 13332 5ustar 0 0 asm-1.5.3/examples/helloworld/etc/ 40755 0 0 0 10146413675 14105 5ustar 0 0 asm-1.5.3/examples/helloworld/src/ 40755 0 0 0 10146413675 14121 5ustar 0 0 asm-1.5.3/examples/xml/ 40755 0 0 0 10146413675 11757 5ustar 0 0 asm-1.5.3/jdoc/ 40755 0 0 0 10146413674 10257 5ustar 0 0 asm-1.5.3/src/ 40755 0 0 0 10146413561 10122 5ustar 0 0 asm-1.5.3/src/org/ 40755 0 0 0 10146413675 10717 5ustar 0 0 asm-1.5.3/src/org/objectweb/ 40755 0 0 0 10146413674 12662 5ustar 0 0 asm-1.5.3/src/org/objectweb/asm/ 40755 0 0 0 10146413675 13443 5ustar 0 0 asm-1.5.3/src/org/objectweb/asm/attrs/ 40755 0 0 0 10146413674 14577 5ustar 0 0 asm-1.5.3/src/org/objectweb/asm/tree/ 40755 0 0 0 10146413675 14402 5ustar 0 0 asm-1.5.3/src/org/objectweb/asm/tree/analysis/ 40755 0 0 0 10146413674 16224 5ustar 0 0 asm-1.5.3/src/org/objectweb/asm/util/ 40755 0 0 0 10146413675 14420 5ustar 0 0 asm-1.5.3/src/org/objectweb/asm/util/attrs/ 40755 0 0 0 10146413675 15555 5ustar 0 0 asm-1.5.3/src/org/objectweb/asm/xml/ 40755 0 0 0 10146413675 14243 5ustar 0 0 asm-1.5.3/test/ 40755 0 0 0 10146413675 10320 5ustar 0 0 asm-1.5.3/test/conform/ 40755 0 0 0 10147410116 11747 5ustar 0 0 asm-1.5.3/test/conform/org/ 40755 0 0 0 10146413674 12551 5ustar 0 0 asm-1.5.3/test/conform/org/objectweb/ 40755 0 0 0 10146413675 14516 5ustar 0 0 asm-1.5.3/test/conform/org/objectweb/asm/ 40755 0 0 0 10146413675 15276 5ustar 0 0 asm-1.5.3/test/conform/org/objectweb/asm/attrs/ 40755 0 0 0 10146413675 16433 5ustar 0 0 asm-1.5.3/test/conform/org/objectweb/asm/tree/ 40755 0 0 0 10146413675 16235 5ustar 0 0 asm-1.5.3/test/conform/org/objectweb/asm/tree/analysis/ 40755 0 0 0 10146413674 20057 5ustar 0 0 asm-1.5.3/test/conform/org/objectweb/asm/xml/ 40755 0 0 0 10146413675 16076 5ustar 0 0 asm-1.5.3/test/perf/ 40755 0 0 0 10146413675 11254 5ustar 0 0 asm-1.5.3/test/perf/org/ 40755 0 0 0 10146413675 12043 5ustar 0 0 asm-1.5.3/test/perf/org/objectweb/ 40755 0 0 0 10146413674 14006 5ustar 0 0 asm-1.5.3/test/perf/org/objectweb/asm/ 40755 0 0 0 10146413674 14566 5ustar 0 0 asm-1.5.3/test/perf/org/objectweb/asm/test/ 40755 0 0 0 10146413675 15546 5ustar 0 0 asm-1.5.3/test/perf/org/objectweb/asm/test/perf/ 40755 0 0 0 10146413675 16502 5ustar 0 0 asm-1.5.3/test/perf/org/objectweb/asm/xml/ 40755 0 0 0 10146413674 15366 5ustar 0 0 asm-1.5.3/.classpath100644 0 0 2370 10146120144 11405 0ustar 0 0 asm-1.5.3/.project100644 0 0 577 10146120144 11060 0ustar 0 0 asm-1.5 org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature asm-1.5.3/LICENSE.txt100644 0 0 3137 10124433442 11253 0ustar 0 0 ASM: a very small and fast Java bytecode manipulation framework Copyright (c) 2000,2002,2003 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. asm-1.5.3/README.txt100644 0 0 1401 10007705133 11115 0ustar 0 0 This directory is the base directory of the product. It contains(*) the following items: - archive: ant files to build the jar(s) of the product, - build.properties: properties to configure the build process, - build.xml: main ant file to build the product, - config: external libraries required only for building the product, - doc: documentation of the product, - etc: scripts to run the product, - examples: examples of use of the product, - externals: external libraires required for running the product, - jdoc: ant files to build the javadoc documentation(s) of the product, - sr': sources of the product, - test: tests of the product, - web: source of the web site of the product. (*) some items may not be present, depending on the product. asm-1.5.3/archive/README.txt100644 0 0 1704 10007705133 12544 0ustar 0 0 This directory contains ant files to build the jars of the product. The following rules describe the convention to write such files: - An ant file must build only one jar file. - The name of the ant file must be the name of the jar it builds: org-foo-bar.xml must build org-foo-bar.jar. - Among the elements which are included into a jar, you must specify a manifest. It is adviced to store the manifest file in this directory. The manifest file can be shared by several jars. The name of the manifest file must be similar to the name of the jar file. - Only the default task is called on each ant file. - The jar file must be produced into the ${dist.lib} directory. Sample ant file: ... asm-1.5.3/archive/asm-analysis.mf100644 0 0 255 10114547245 13762 0ustar 0 0 Manifest-Version: 1.0 Implementation-Title: "ASM static code analysis framework" Implementation-Version: "@product.version@" Implementation-Vendor: "France Telecom R&D" asm-1.5.3/archive/asm-analysis.xml100644 0 0 1734 10124433442 14175 0ustar 0 0 asm-1.5.3/archive/asm-attrs.mf100644 0 0 240 10114547245 13266 0ustar 0 0 Manifest-Version: 1.0 Implementation-Title: "ASM Attribute classes" Implementation-Version: "@product.version@" Implementation-Vendor: "France Telecom R&D" asm-1.5.3/archive/asm-attrs.xml100644 0 0 1704 10124433442 13504 0ustar 0 0 asm-1.5.3/archive/asm-tree.mf100644 0 0 241 10114547245 13071 0ustar 0 0 Manifest-Version: 1.0 Implementation-Title: "ASM Tree class visitor" Implementation-Version: "@product.version@" Implementation-Vendor: "France Telecom R&D" asm-1.5.3/archive/asm-tree.xml100644 0 0 1703 10124433442 13305 0ustar 0 0 asm-1.5.3/archive/asm-util.mf100644 0 0 230 10114547245 13105 0ustar 0 0 Manifest-Version: 1.0 Implementation-Title: "ASM Utilities" Implementation-Version: "@product.version@" Implementation-Vendor: "France Telecom R&D" asm-1.5.3/archive/asm-util.xml100644 0 0 1675 10124433442 13333 0ustar 0 0 asm-1.5.3/archive/asm-xml.mf100644 0 0 362 10114547245 12736 0ustar 0 0 Manifest-Version: 1.0 Implementation-Title: "ASM XML classes" Implementation-Version: "@product.version@" Implementation-Vendor: "Eugene Kuleshov" Class-path: asm.jar asm-util.jar asm-attrs.jar Main-class: org.objectweb.asm.xml.Processorasm-1.5.3/archive/asm-xml.xml100644 0 0 2217 10124433442 13147 0ustar 0 0 asm-1.5.3/archive/asm.mf100644 0 0 216 10114547245 12136 0ustar 0 0 Manifest-Version: 1.0 Implementation-Title: "ASM" Implementation-Version: "@product.version@" Implementation-Vendor: "France Telecom R&D" asm-1.5.3/archive/asm.xml100644 0 0 1646 10124433442 12356 0ustar 0 0 asm-1.5.3/archive/kasm.mf100644 0 0 302 10114547245 12305 0ustar 0 0 Manifest-Version: 1.0 Implementation-Title: "kASM (reduced version of ASM, for code generation only)" Implementation-Version: "@product.version@" Implementation-Vendor: "France Telecom R&D" asm-1.5.3/archive/kasm.xml100644 0 0 2223 10124433442 12521 0ustar 0 0 asm-1.5.3/archive/maven-pom-template.xml100644 0 0 1750 10124433442 15302 0ustar 0 0 3 @product.name@ @product.name@ asm @product.version@ ObjectWeb http://www.objectweb.org/ 2000 A very small and fast Java bytecode manipulation framework http://asm.objectweb.org/ Eric Bruneton ebruneton Eric.Bruneton@rd.francetelecom.com Creator Java Developer Eugene Kuleshov eu eu@javatx.org Java Developer asm-1.5.3/build.properties100644 0 0 6717 10174143172 12657 0ustar 0 0 ############################################################################### #ASM: a very small and fast Java bytecode manipulation framework #Copyright (c) 2000,2002,2003 INRIA, France Telecom #All rights reserved. # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions #are met: #1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. #2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. #3. Neither the name of the copyright holders nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" #AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE #IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE #ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE #LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR #CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF #SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS #INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN #CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) #ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF #THE POSSIBILITY OF SUCH DAMAGE. ############################################################################### # Some information about the product product.name asm product.version 1.5.3 ############################################################################### # BUILD ############################################################################### # Wich compiler do you want to use ? # jikes is faster than javac but keeps line numbers in compiled classes, even # with the -O option (javac removes line numbers and local variable names with # this option, resulting in smaller classes) build.compiler modern # Build class path (classes needed to build the project) # Class path for the ObjectWeb utility Ant tasks (version 1.2 or higher) # See http://forge.objectweb.org/projects/monolog # objectweb.ant.tasks.path ow_util_ant_tasks.jar ############################################################################### # TESTS (PERFORMANCE COMPARISONS WITH BCEL AND SERP) ############################################################################### # Class path for the BCEL library (version 5.0) # See http://jakarta.apache.org/bcel # bcel.path bcel.jar # Class path for the SERP library (version 1.4.2) # See http://serp.sourceforge.net # serp.path serp.jar # Class path for the Javassist library (version 2.6) # See http://www.csg.is.titech.ac.jp/~chiba/javassist # javassist.path javassist.jar # Class path for the Janino compiler (version 2.0.10) # See http://www.janino.net/ # janino.path janino.jar ############################################################################### # DOCUMENTATION ############################################################################### # URLs of external Javadocs (JDK) jdk.url http://java.sun.com/j2se/1.4.2/docs/api asm-1.5.3/build.xml100644 0 0 26220 10124175353 11273 0ustar 0 0 asm-1.5.3/doc/README.txt100644 0 0 73 10007750443 11632 0ustar 0 0 This directory contains the documentation of the product. asm-1.5.3/examples/adapt/README100644 0 0 65 7513254643 13150 0ustar 0 0 This file must contain a description of the example asm-1.5.3/examples/adapt/etc/execute.properties100644 0 0 56 7615213177 16623 0ustar 0 0 run.classname Adapt run.parameters ArraySet asm-1.5.3/examples/adapt/src/Adapt.java100644 0 0 16342 10112601423 15035 0ustar 0 0 /*** * ASM examples: examples showing how ASM can be used * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ import org.objectweb.asm.ClassAdapter; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.CodeAdapter; import org.objectweb.asm.CodeVisitor; import org.objectweb.asm.Constants; import org.objectweb.asm.Type; import org.objectweb.asm.Attribute; import java.io.FileOutputStream; import java.io.InputStream; import java.lang.reflect.Method; /** * @author Eric Bruneton */ public class Adapt extends ClassLoader { protected synchronized Class loadClass ( final String name, final boolean resolve) throws ClassNotFoundException { if (name.startsWith("java.")) { System.err.println( "Adapt: loading class '" + name + "' without on the fly adaptation"); return super.loadClass(name, resolve); } else { System.err.println( "Adapt: loading class '" + name + "' with on the fly adaptation"); } // gets an input stream to read the bytecode of the class String resource = name.replace('.','/') + ".class"; InputStream is = getResourceAsStream(resource); byte[] b; // adapts the class on the fly try { ClassReader cr = new ClassReader(is); ClassWriter cw = new ClassWriter(false); ClassVisitor cv = new TraceFieldClassAdapter(cw); cr.accept(cv, false); b = cw.toByteArray(); } catch (Exception e) { throw new ClassNotFoundException(name, e); } // optional: stores the adapted class on disk try { FileOutputStream fos = new FileOutputStream(resource + ".adapted"); fos.write(b); fos.close(); } catch (Exception e) { } // returns the adapted class return defineClass(name, b, 0, b.length); } public static void main (final String args[]) throws Exception { // loads the application class (in args[0]) with an Adapt class loader ClassLoader loader = new Adapt(); Class c = loader.loadClass(args[0]); // calls the 'main' static method of this class with the // application arguments (in args[1] ... args[n]) as parameter Method m = c.getMethod("main", new Class[] {String[].class}); String[] applicationArgs = new String[args.length - 1]; System.arraycopy(args, 1, applicationArgs, 0, applicationArgs.length); m.invoke(null, new Object[] {applicationArgs}); } } class TraceFieldClassAdapter extends ClassAdapter implements Constants { private String owner; public TraceFieldClassAdapter (final ClassVisitor cv) { super(cv); } public void visit ( final int version, final int access, final String name, final String superName, final String[] interfaces, final String sourceFile) { owner = name; super.visit(version, access, name, superName, interfaces, sourceFile); } public void visitField ( final int access, final String name, final String desc, final Object value, final Attribute attrs) { super.visitField(access, name, desc, value, attrs); if ((access & ACC_STATIC) == 0) { Type t = Type.getType(desc); int size = t.getSize(); // generates getter method String gDesc = "()" + desc; CodeVisitor gv = cv.visitMethod(ACC_PRIVATE, "_get" + name, gDesc, null, null); gv.visitFieldInsn(GETSTATIC, "java/lang/System", "err", "Ljava/io/PrintStream;"); gv.visitLdcInsn("_get" + name + " called"); gv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V"); gv.visitVarInsn(ALOAD, 0); gv.visitFieldInsn(GETFIELD, owner, name, desc); gv.visitInsn(t.getOpcode(IRETURN)); gv.visitMaxs(1 + size, 1); // generates setter method String sDesc = "(" + desc + ")V"; CodeVisitor sv = cv.visitMethod(ACC_PRIVATE, "_set" + name, sDesc, null, null); sv.visitFieldInsn(GETSTATIC, "java/lang/System", "err", "Ljava/io/PrintStream;"); sv.visitLdcInsn("_set" + name + " called"); sv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V"); sv.visitVarInsn(ALOAD, 0); sv.visitIntInsn(t.getOpcode(ILOAD), 1); sv.visitFieldInsn(PUTFIELD, owner, name, desc); sv.visitInsn(RETURN); sv.visitMaxs(1 + size, 1 + size); } } public CodeVisitor visitMethod ( final int access, final String name, final String desc, final String[] exceptions, final Attribute attrs) { CodeVisitor mv = cv.visitMethod(access, name, desc, exceptions, attrs); return mv == null ? null : new TraceFieldCodeAdapter(mv, owner); } } class TraceFieldCodeAdapter extends CodeAdapter implements Constants { private String owner; public TraceFieldCodeAdapter (final CodeVisitor cv, final String owner) { super(cv); this.owner = owner; } public void visitFieldInsn ( final int opcode, final String owner, final String name, final String desc) { if (owner.equals(this.owner)) { if (opcode == GETFIELD) { // replaces GETFIELD f by INVOKESPECIAL _getf String gDesc = "()" + desc; visitMethodInsn(INVOKESPECIAL, owner, "_get" + name, gDesc); return; } else if (opcode == PUTFIELD) { // replaces PUTFIELD f by INVOKESPECIAL _setf String sDesc = "(" + desc + ")V"; visitMethodInsn(INVOKESPECIAL, owner, "_set" + name, sDesc); return; } } super.visitFieldInsn(opcode, owner, name, desc); } } asm-1.5.3/examples/adapt/src/ArraySet.java100644 0 0 6067 10026564547 15544 0ustar 0 0 /*** * ASM examples: examples showing how ASM can be used * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ /** * @author Eric Bruneton */ public class ArraySet { private int[] values = new int[3]; private int size; public boolean contains (int v) { for (int i = 0; i < size; ++i) { if (values[i] == v) { return true; } } return false; } public void add (int v) { if (!contains(v)) { if (size == values.length) { System.err.println("[enlarge]"); int[] newValues = new int[values.length + 3]; for (int i = 0; i < size; ++i) { newValues[i] = values[i]; } values = newValues; } values[size++] = v; } } public void remove (int v) { int i = 0; int j = 0; while (i < size) { int u = values[i]; if (u != v) { values[j++] = u; } ++i; } size = j; } // test method public static void main (String[] args) { ArraySet s = new ArraySet(); System.err.println("add 1"); s.add(1); System.err.println("add 1"); s.add(1); System.err.println("add 2"); s.add(2); System.err.println("add 4"); s.add(4); System.err.println("add 8"); s.add(8); System.err.println("contains 3 = " + s.contains(3)); System.err.println("contains 1 = " + s.contains(1)); System.err.println("remove 1"); s.remove(1); System.err.println("contains 1 = " + s.contains(1)); } } asm-1.5.3/examples/analysis/etc/execute.properties100644 0 0 50 10035530140 17345 0ustar 0 0 run.classname Analysis run.parameters asm-1.5.3/examples/analysis/src/Analysis.java100644 0 0 15234 10075731026 16333 0ustar 0 0 /*** * ASM examples: examples showing how ASM can be used * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import org.objectweb.asm.ClassReader; import org.objectweb.asm.Constants; import org.objectweb.asm.Label; import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.IincInsnNode; import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.TreeClassAdapter; import org.objectweb.asm.tree.VarInsnNode; import org.objectweb.asm.tree.analysis.Analyzer; import org.objectweb.asm.tree.analysis.BasicVerifier; import org.objectweb.asm.tree.analysis.DataflowInterpreter; import org.objectweb.asm.tree.analysis.DataflowValue; import org.objectweb.asm.tree.analysis.Frame; import org.objectweb.asm.util.TraceCodeVisitor; /** * @author Eric Bruneton */ public class Analysis implements Constants { public static void main (String[] args) throws Exception { ClassReader cr = new ClassReader("Analysis"); TreeClassAdapter ca = new TreeClassAdapter(null); cr.accept(ca, true); List methods = ca.classNode.methods; for (int i = 0; i < methods.size(); ++i) { MethodNode method = (MethodNode)methods.get(i); if (method.instructions.size() > 0) { if (!analyze(ca.classNode, method)) { Analyzer a = new Analyzer(new BasicVerifier()); try { a.analyze(ca.classNode, method); } catch (Exception ignored) { } final Frame[] frames = a.getFrames(); TraceCodeVisitor cv = new TraceCodeVisitor(null) { public void visitMaxs (int maxStack, int maxLocals) { for (int i = 0; i < text.size(); ++i) { String s = frames[i] == null ? "null" : frames[i].toString(); while (s.length() < Math.max(20, maxStack+maxLocals+1)) { s += " "; } System.err.print( Integer.toString(i + 1000).substring(1) + " " + s + " : " + text.get(i)); } System.err.println(); } }; for (int j = 0; j < method.instructions.size(); ++j) { Object insn = method.instructions.get(j); if (insn instanceof AbstractInsnNode) { ((AbstractInsnNode)insn).accept(cv); } else { cv.visitLabel((Label)insn); } } cv.visitMaxs(0, 0); } } } } /* * Detects unused xSTORE instructions, i.e. xSTORE instructions without at * least one xLOAD corresponding instruction in their successor instructions * (in the control flow graph). */ public static boolean analyze (ClassNode c, MethodNode m) throws Exception { Analyzer a = new Analyzer(new DataflowInterpreter()); Frame[] frames = a.analyze(c, m); // for each xLOAD instruction, we find the xSTORE instructions that can // produce the value loaded by this instruction, and we put them in 'stores' Set stores = new HashSet(); for (int i = 0; i < m.instructions.size(); ++i) { Object insn = m.instructions.get(i); if (insn instanceof AbstractInsnNode) { int opcode = ((AbstractInsnNode)insn).getOpcode(); if ((opcode >= ILOAD && opcode <= ALOAD) || opcode == IINC) { int var = (opcode == IINC ? ((IincInsnNode)insn).var : ((VarInsnNode)insn).var); Frame f = frames[i]; if (f != null) { Set s = ((DataflowValue)f.getLocal(var)).insns; Iterator j = s.iterator(); while (j.hasNext()) { insn = j.next(); if (insn instanceof VarInsnNode) { stores.add(insn); } } } } } } // we then find all the xSTORE instructions that are not in 'stores' boolean ok = true; for (int i = 0; i < m.instructions.size(); ++i) { Object insn = m.instructions.get(i); if (insn instanceof AbstractInsnNode) { int opcode = ((AbstractInsnNode)insn).getOpcode(); if (opcode >= ISTORE && opcode <= ASTORE) { if (!stores.contains(insn)) { ok = false; System.err.println( "method " + m.name + ", instruction " + i + ": useless store instruction"); } } } } return ok; } /* * Test for the above method, with three useless xSTORE instructions. */ public int test (int i, int j) { i = i + 1; // ok, because i can be read after this point if (j == 0) { j = 1; // useless } else { try { j = j - 1; // ok, because j can be accessed in the exception handler int k = 0; if (i > 0) { k = i - 1; } return k; } catch (Exception e) { // useless ASTORE instruction (e is never used) j = j + 1; // useless } } return 0; } } asm-1.5.3/examples/annotations/build.xml100644 0 0 2407 10124174740 15426 0ustar 0 0 asm-1.5.3/examples/annotations/src15/annotations/ValueAttrAnnotation.java100644 0 0 332 10123542205 23651 0ustar 0 0 package annotations; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) public @interface ValueAttrAnnotation { String value(); } asm-1.5.3/examples/annotations/src15/annotations/Values.java100644 0 0 1633 10124175011 21171 0ustar 0 0 package annotations; @ValuesAnnotation( byteValue = 1, charValue = 'A', booleanValue = true, intValue = 1, shortValue = 1, longValue = 1L, floatValue = 1.0f, doubleValue = 1.0d, stringValue = "A", enumValue = ValuesEnum.ONE, annotationValue = @ValueAttrAnnotation( "annotation"), classValue = Values.class, byteArrayValue = { 1, -1}, charArrayValue = { 'c', 'b', (char)-1}, booleanArrayValue = {true, false}, intArrayValue = { 1, -1}, shortArrayValue = { (short)1, (short)-1}, longArrayValue = { 1L, -1L}, floatArrayValue = { 1.0f, -1.0f}, doubleArrayValue = { 1.0d, -1.0d}, stringArrayValue = { "aa", "bb"}, enumArrayValue = {ValuesEnum.ONE, ValuesEnum.TWO}, annotationArrayValue = {@ValueAttrAnnotation( "annotation1"), @ValueAttrAnnotation( "annotation2")}, classArrayValue = {Values.class, Values.class} ) public class Values { } asm-1.5.3/examples/annotations/src15/annotations/ValuesAnnotation.java100644 0 0 1723 10123542205 23226 0ustar 0 0 package annotations; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Annotation declaration with different values */ @Retention(RetentionPolicy.RUNTIME) public @interface ValuesAnnotation { byte byteValue(); char charValue(); boolean booleanValue(); int intValue(); short shortValue(); long longValue(); float floatValue(); double doubleValue(); String stringValue(); ValuesEnum enumValue(); ValueAttrAnnotation annotationValue(); Class classValue(); byte[] byteArrayValue(); char[] charArrayValue(); boolean[] booleanArrayValue(); int[] intArrayValue(); short[] shortArrayValue(); long[] longArrayValue(); float[] floatArrayValue(); double[] doubleArrayValue(); String[] stringArrayValue(); ValuesEnum[] enumArrayValue(); ValueAttrAnnotation[] annotationArrayValue(); Class[] classArrayValue(); } asm-1.5.3/examples/annotations/src15/annotations/ValuesDump.java100644 0 0 6170 10124175011 22020 0ustar 0 0 package annotations; import org.objectweb.asm.*; import org.objectweb.asm.attrs.*; import java.util.*; public class ValuesDump implements Constants { public static byte[] dump () throws Exception { ClassWriter cw = new ClassWriter(false); CodeVisitor cv; cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "annotations/Values", "java/lang/Object", null, "Values.java"); { cv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); cv.visitVarInsn(ALOAD, 0); cv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V"); cv.visitInsn(RETURN); cv.visitMaxs(1, 1); } { // CLASS ATRIBUTE RuntimeVisibleAnnotations attr = new RuntimeVisibleAnnotations(); { Annotation attrann0 = new Annotation("Lannotations/ValuesAnnotation;"); attrann0.add( "byteValue", new Byte((byte)1)); attrann0.add( "charValue", new Character((char)65)); attrann0.add( "booleanValue", new Boolean(true)); attrann0.add( "intValue", new Integer(1)); attrann0.add( "shortValue", new Short((short)1)); attrann0.add( "longValue", new Long(1L)); attrann0.add( "floatValue", new Float(1.0f)); attrann0.add( "doubleValue", new Double(1.0d)); attrann0.add( "stringValue", "A"); attrann0.add( "enumValue", new Annotation.EnumConstValue("Lannotations/ValuesEnum;", "ONE")); Annotation attrann0val10 = new Annotation("Lannotations/ValueAttrAnnotation;"); attrann0val10.add( "value", "annotation"); attrann0.add( "annotationValue", attrann0val10); attrann0.add( "classValue", Type.getType("Lannotations/Values;")); attrann0.add( "byteArrayValue", new byte[] {1, -1}); attrann0.add( "charArrayValue", new char[] {(char)99, (char)98, (char)65535}); attrann0.add( "booleanArrayValue", new boolean[] {true, false}); attrann0.add( "intArrayValue", new int[] {1, -1}); attrann0.add( "shortArrayValue", new short[] {(short)1, (short)-1}); attrann0.add( "longArrayValue", new long[] {1L, -1L}); attrann0.add( "floatArrayValue", new float[] {1.0f, -1.0f}); attrann0.add( "doubleArrayValue", new double[] {1.0d, -1.0d}); Object[] attrann0val20 = new Object[2]; attrann0val20[0] = "aa"; attrann0val20[1] = "bb"; attrann0.add( "stringArrayValue", attrann0val20); Object[] attrann0val21 = new Object[2]; attrann0val21[0] = new Annotation.EnumConstValue("Lannotations/ValuesEnum;", "ONE"); attrann0val21[1] = new Annotation.EnumConstValue("Lannotations/ValuesEnum;", "TWO"); attrann0.add( "enumArrayValue", attrann0val21); Object[] attrann0val22 = new Object[2]; Annotation attrann0val22Arr0 = new Annotation("Lannotations/ValueAttrAnnotation;"); attrann0val22Arr0.add( "value", "annotation1"); attrann0val22[0] = attrann0val22Arr0; Annotation attrann0val22Arr1 = new Annotation("Lannotations/ValueAttrAnnotation;"); attrann0val22Arr1.add( "value", "annotation2"); attrann0val22[1] = attrann0val22Arr1; attrann0.add( "annotationArrayValue", attrann0val22); Object[] attrann0val23 = new Object[2]; attrann0val23[0] = Type.getType("Lannotations/Values;"); attrann0val23[1] = Type.getType("Lannotations/Values;"); attrann0.add( "classArrayValue", attrann0val23); attr.annotations.add( attrann0); } cw.visitAttribute(attr); } cw.visitEnd(); return cw.toByteArray(); } } asm-1.5.3/examples/annotations/src15/annotations/ValuesEnum.java100644 0 0 115 10123542205 21772 0ustar 0 0 package annotations; public enum ValuesEnum { ONE, TWO, THREE; } asm-1.5.3/examples/annotations/src15/annotations/ValuesTest.java100644 0 0 10556 10124175011 22055 0ustar 0 0 package annotations; import java.lang.annotation.Annotation; import junit.framework.TestCase; public class ValuesTest extends TestCase { private ValuesAnnotation a; protected void setUp() throws Exception { TestClassLoader cl = new TestClassLoader( "annotations.Values", getClass().getClassLoader()); Class c = cl.loadClass( "annotations.Values"); Annotation[] annotations = c.getAnnotations(); a = ( ValuesAnnotation) annotations[ 0]; } public void testByteValue() { assertEquals( 1, a.byteValue()); } public void testCharValue() { assertEquals( 'A', a.charValue()); } public void testBooleanValue() { assertEquals( true, a.booleanValue()); } public void testIntValue() { assertEquals( 1, a.intValue()); } public void testShortValue() { assertEquals( 1, a.shortValue()); } public void testLongValue() { assertEquals( 1L, a.longValue()); } public void testFloatValue() { assertEquals( 1.0f, a.floatValue(), 0.1f); } public void testDoubleValue() { assertEquals( 1.0d, a.doubleValue(), 0.1d); } public void testStringValue() { assertEquals( "A", a.stringValue()); } public void testAnnotationValue() { ValueAttrAnnotation ann = a.annotationValue(); assertEquals( "annotation", ann.value()); } public void testEnumValue() { ValuesEnum en = a.enumValue(); assertEquals( ValuesEnum.ONE, en); } public void testClassValue() { Class c = a.classValue(); assertEquals( Values.class.getName(), c.getName()); } public void testByteArrayValue() { byte[] bs = a.byteArrayValue(); assertEquals( 1, bs[0]); assertEquals( -1, bs[1]); } public void testCharArrayValue() { char[] bs = a.charArrayValue(); assertEquals( 'c', bs[0]); assertEquals( 'b', bs[1]); assertEquals((char) -1, bs[2]); } public void testBooleanArrayValue() { boolean[] bs = a.booleanArrayValue(); assertEquals( true, bs[0]); assertEquals( false, bs[1]); } public void testIntArrayValue() { int[] bs = a.intArrayValue(); assertEquals( 1, bs[0]); assertEquals( -1, bs[1]); } public void testShortArrayValue() { short[] bs = a.shortArrayValue(); assertEquals( 1, bs[0]); assertEquals( -1, bs[1]); } public void testLongArrayValue() { long[] bs = a.longArrayValue(); assertEquals( 1L, bs[0]); assertEquals( -1L, bs[1]); } public void testFloatArrayValue() { float[] bs = a.floatArrayValue(); assertEquals( 1.0f, bs[0], 0.1f); assertEquals( -1.0f, bs[1], 0.1f); } public void testDoubleArrayValue() { double[] bs = a.doubleArrayValue(); assertEquals( 1.0d, bs[0], 0.1d); assertEquals( -1.0d, bs[1], 0.1d); } public void testStringArrayValue() { String[] s = a.stringArrayValue(); assertEquals( "aa", s[0]); assertEquals( "bb", s[1]); } public void testAnnotationArrayValue() { ValueAttrAnnotation[] ann = a.annotationArrayValue(); assertEquals( "annotation1", ann[0].value()); assertEquals( "annotation2", ann[1].value()); } public void testEnumArrayValue() { ValuesEnum[] en = a.enumArrayValue(); assertEquals( ValuesEnum.ONE, en[0]); assertEquals( ValuesEnum.TWO, en[1]); } public void testClassArrayValue() { Class[] c = a.classArrayValue(); assertEquals( Values.class.getName(), c[0].getName()); assertEquals( Values.class.getName(), c[1].getName()); } private static final class TestClassLoader extends ClassLoader { private final String className; private final ClassLoader loader; public TestClassLoader(String className, ClassLoader loader) { super(); this.className = className; this.loader = loader; } public Class loadClass( String name) throws ClassNotFoundException { if( className.equals( name)) { try { byte[] bytecode = ValuesDump.dump(); return super.defineClass( className, bytecode, 0, bytecode.length); } catch( Exception ex) { ex.printStackTrace(); throw new ClassNotFoundException( "Load error: "+ex.toString(), ex); } } return loader.loadClass( name); } } } asm-1.5.3/examples/attributes/etc/execute.properties100644 0 0 52 7754641540 17717 0ustar 0 0 run.classname Attributes run.parameters asm-1.5.3/examples/attributes/src/Attributes.java100644 0 0 11717 10112601423 17230 0ustar 0 0 /*** * ASM examples: examples showing how ASM can be used * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassAdapter; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.CodeVisitor; import org.objectweb.asm.Constants; import org.objectweb.asm.Label; import org.objectweb.asm.ByteVector; import org.objectweb.asm.util.TraceClassVisitor; import java.io.FileOutputStream; import java.io.PrintWriter; /** * @author Eric Bruneton */ public class Attributes extends ClassLoader { public static void main (final String args[]) throws Exception { // loads the original class and adapts it ClassReader cr = new ClassReader("CommentAttribute"); ClassWriter cw = new ClassWriter(false); ClassVisitor cv = new AddCommentClassAdapter(cw); cr.accept(cv, new Attribute[] { new CommentAttribute("") }, false); byte[] b = cw.toByteArray(); // stores the adapted class on disk FileOutputStream fos = new FileOutputStream("CommentAttribute.class.new"); fos.write(b); fos.close(); // "disassembles" the adapted class cr = new ClassReader(b); cv = new TraceClassVisitor(null, new PrintWriter(System.out)); cr.accept(cv, new Attribute[] { new CommentAttribute("") }, false); } } class AddCommentClassAdapter extends ClassAdapter implements Constants { public AddCommentClassAdapter (final ClassVisitor cv) { super(cv); } public void visit ( final int version, final int access, final String name, final String superName, final String[] interfaces, final String sourceFile) { super.visit(version, access, name, superName, interfaces, sourceFile); visitAttribute(new CommentAttribute("this is a class comment")); } public void visitField ( final int access, final String name, final String desc, final Object value, final Attribute attrs) { super.visitField( access, name, desc, value, new CommentAttribute("this is a field comment", attrs)); } public CodeVisitor visitMethod ( final int access, final String name, final String desc, final String[] exceptions, final Attribute attrs) { CodeVisitor mv = cv.visitMethod( access, name, desc, exceptions, new CommentAttribute("this is a method comment", attrs)); if (mv != null) { mv.visitAttribute(new CommentAttribute("this is a code comment")); } return mv; } } class CommentAttribute extends Attribute { private String comment; public CommentAttribute (final String comment) { super("Comment"); this.comment = comment; } public CommentAttribute (final String comment, final Attribute next) { super("Comment"); this.comment = comment; this.next = next; } public String getComment () { return comment; } protected Attribute read ( ClassReader cr, int off, int len, char[] buf, int codeOff, Label[] labels) { return new CommentAttribute(cr.readUTF8(off, buf)); } protected ByteVector write ( ClassWriter cw, byte[] code, int len, int maxStack, int maxLocals) { return new ByteVector().putShort(cw.newUTF8(comment)); } } asm-1.5.3/examples/common/README.txt100644 0 0 1113 10007705133 14223 0ustar 0 0 This directory contains the examples of the product. It contains(*) the following items: - lib: jar files shared by all examples, - etc: configuration files shared by all examples, - README.txt: explains the organisation of the examples directory, - all other directories contain(*) the following items: - README.txt file: describes the example and its configuration, - lib: jar files needed by the example, - etc: configuration files needed by the example, - src: source code of the example. (*) some items may not be present, depending on the product or example.asm-1.5.3/examples/common/build.xml100644 0 0 6727 10035530140 14361 0ustar 0 0 asm-1.5.3/examples/common/etc/build.properties100644 0 0 1526 10124175410 16524 0ustar 0 0 # Wich compiler do you want use ? build.compiler jikes # Class path for the ASM library (version @product.version@) # See http://asm.objectweb.org asm.path ../../lib/asm-@product.version@.jar # Class path for the ASM tree library (version @product.version@) # See http://asm.objectweb.org asm.tree.path ../../lib/asm-tree-@product.version@.jar # Class path for the ASM analysis library (version @product.version@) # See http://asm.objectweb.org asm.analysis.path ../../lib/asm-analysis-@product.version@.jar # Class path for the ASM attrs library (version @product.version@) # See http://asm.objectweb.org asm.attrs.path ../../lib/asm-attrs-@product.version@.jar # Class path for the ASM util library (version @product.version@) # See http://asm.objectweb.org asm.util.path ../../lib/asm-util-@product.version@.jar asm-1.5.3/examples/compile/README100644 0 0 65 7513254643 13507 0ustar 0 0 This file must contain a description of the example asm-1.5.3/examples/compile/etc/execute.properties100644 0 0 47 7513254643 17162 0ustar 0 0 run.classname Compile run.parameters asm-1.5.3/examples/compile/src/Compile.java100644 0 0 16522 10112601423 15733 0ustar 0 0 /*** * ASM examples: examples showing how ASM can be used * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ import org.objectweb.asm.ClassWriter; import org.objectweb.asm.CodeVisitor; import org.objectweb.asm.Constants; import org.objectweb.asm.Label; import java.io.FileOutputStream; /** * @author Eric Bruneton */ public class Compile extends ClassLoader { public static void main (String[] args) throws Exception { // creates the expression tree corresponding to // exp(i) = i > 3 && 6 > i Exp exp = new And(new GT(new Var(0), new Cst(3)), new GT(new Cst(6), new Var(0))); // compiles this expression into an Expression class Compile main = new Compile(); byte[] b = exp.compile("Example"); FileOutputStream fos = new FileOutputStream("Example.class"); fos.write(b); fos.close(); Class expClass = main.defineClass("Example", b, 0, b.length); // instantiates this compiled expression class... Expression iexp = (Expression)expClass.newInstance(); // ... and uses it to evaluate exp(0) to exp(9) for (int i = 0; i < 10; ++i) { boolean val = iexp.eval(i, 0) == 1; System.out.println(i + " > 3 && " + i + " < 6 = " + val); } } } /** * An abstract expression. * * @author Eric Bruneton */ abstract class Exp implements Constants { /* * Returns the byte code of an Expression class corresponding to this * expression. */ byte[] compile (String name) { // class header String[] itfs = {Expression.class.getName()}; ClassWriter cw = new ClassWriter(true); cw.visit(V1_1, ACC_PUBLIC, name, "java/lang/Object", itfs, null); // default public constructor CodeVisitor mw = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); mw.visitVarInsn(ALOAD, 0); mw.visitMethodInsn( INVOKESPECIAL, "java/lang/Object", "", "()V"); mw.visitInsn(RETURN); mw.visitMaxs(1, 1); // eval method mw = cw.visitMethod(ACC_PUBLIC, "eval", "(II)I", null, null); compile(mw); mw.visitInsn(IRETURN); // max stack and max locals automatically computed mw.visitMaxs(0, 0); return cw.toByteArray(); } /* * Compile this expression. This method must append to the given code * writer the byte code that evaluates and pushes on the stack the * value of this expression. */ abstract void compile (CodeVisitor mw); } /** * A constant expression. */ class Cst extends Exp { int value; Cst (int value) { this.value = value; } void compile (CodeVisitor mw) { // pushes the constant's value onto the stack mw.visitLdcInsn(new Integer(value)); } } /** * A variable reference expression. */ class Var extends Exp { int index; Var (int index) { this.index = index + 1; } void compile (CodeVisitor mb) { // pushes the 'index' local variable onto the stack mb.visitVarInsn(ILOAD, index); } } /** * An abstract binary expression. */ abstract class BinaryExp extends Exp { Exp e1; Exp e2; BinaryExp (Exp e1, Exp e2) { this.e1 = e1; this.e2 = e2; } } /** * An addition expression. */ class Add extends BinaryExp { Add (Exp e1, Exp e2) { super(e1, e2); } void compile (CodeVisitor mw) { // compiles e1, e2, and adds an instruction to add the two values e1.compile(mw); e2.compile(mw); mw.visitInsn(IADD); } } /** * A multiplication expression. */ class Mul extends BinaryExp { Mul (Exp e1, Exp e2) { super(e1, e2); } void compile (CodeVisitor mb) { // compiles e1, e2, and adds an instruction to multiply the two values e1.compile(mb); e2.compile(mb); mb.visitInsn(IMUL); } } /** * A "greater than" expression. */ class GT extends BinaryExp { GT (Exp e1, Exp e2) { super(e1, e2); } void compile (CodeVisitor mw) { // compiles e1, e2, and adds the instructions to compare the two values e1.compile(mw); e2.compile(mw); Label iftrue = new Label(); Label end = new Label(); mw.visitJumpInsn(IF_ICMPGT, iftrue); // case where e1 <= e2 : pushes false and jump to "end" mw.visitInsn(ICONST_0); mw.visitJumpInsn(GOTO, end); // case where e1 > e2 : pushes true mw.visitLabel(iftrue); mw.visitInsn(ICONST_1); mw.visitLabel(end); } } /** * A logical "and" expression. */ class And extends BinaryExp { And (Exp e1, Exp e2) { super(e1, e2); } void compile (CodeVisitor mw) { // compiles e1 e1.compile(mw); // tests if e1 is false mw.visitInsn(DUP); Label end = new Label(); mw.visitJumpInsn(IFEQ, end); // case where e1 is true : e1 && e2 is equal to e2 mw.visitInsn(POP); e2.compile(mw); // if e1 is false, e1 && e2 is equal to e1: // we jump directly to this label, without evaluating e2 mw.visitLabel(end); } } /** * A logical "or" expression. */ class Or extends BinaryExp { Or (Exp e1, Exp e2) { super(e1, e2); } void compile (CodeVisitor mw) { // compiles e1 e1.compile(mw); // tests if e1 is true mw.visitInsn(DUP); Label end = new Label(); mw.visitJumpInsn(IFNE, end); // case where e1 is false : e1 || e2 is equal to e2 mw.visitInsn(POP); e2.compile(mw); // if e1 is true, e1 || e2 is equal to e1: // we jump directly to this label, without evaluating e2 mw.visitLabel(end); } } /** * A logical "not" expression. */ class Not extends Exp { Exp e; Not (Exp e) { this.e = e; } void compile (CodeVisitor mw) { // computes !e1 by evaluating 1 - e1 mw.visitInsn(ICONST_1); e.compile(mw); mw.visitInsn(ISUB); } } asm-1.5.3/examples/compile/src/Expression.java100644 0 0 4036 10026564547 16502 0ustar 0 0 /*** * ASM examples: examples showing how ASM can be used * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ /** * An integer or boolean expression of at most two variables. * * @author Eric Bruneton */ public interface Expression { /** * Evaluates this expression. * * @param i the value of the first variable. * @param j the value of the second variable. * @return the value of this expression for the given variable values. */ int eval (int i, int j); } asm-1.5.3/examples/helloworld/README100644 0 0 65 7513254643 14232 0ustar 0 0 This file must contain a description of the example asm-1.5.3/examples/helloworld/etc/execute.properties100644 0 0 52 7513254643 17701 0ustar 0 0 run.classname Helloworld run.parameters asm-1.5.3/examples/helloworld/src/Helloworld.java100644 0 0 10050 10112601423 17167 0ustar 0 0 /*** * ASM examples: examples showing how ASM can be used * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ import org.objectweb.asm.*; import java.lang.reflect.*; import java.io.FileOutputStream; /** * @author Eric Bruneton */ public class Helloworld extends ClassLoader implements Constants { public static void main (final String args[]) throws Exception { /* * Generates the bytecode corresponding to the following Java class: * * public class Example { * public static void main (String[] args) { * System.out.println("Hello world!"); * } * } * */ // creates a ClassWriter for the Example public class, // which inherits from Object ClassWriter cw = new ClassWriter(false); cw.visit(V1_1, ACC_PUBLIC, "Example", "java/lang/Object", null, null); // creates a MethodWriter for the (implicit) constructor CodeVisitor mw = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); // pushes the 'this' variable mw.visitVarInsn(ALOAD, 0); // invokes the super class constructor mw.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V"); mw.visitInsn(RETURN); // this code uses a maximum of one stack element and one local variable mw.visitMaxs(1, 1); // creates a MethodWriter for the 'main' method mw = cw.visitMethod( ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null); // pushes the 'out' field (of type PrintStream) of the System class mw.visitFieldInsn( GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); // pushes the "Hello World!" String constant mw.visitLdcInsn("Hello world!"); // invokes the 'println' method (defined in the PrintStream class) mw.visitMethodInsn( INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V"); mw.visitInsn(RETURN); // this code uses a maximum of two stack elements and two local variables mw.visitMaxs(2, 2); // gets the bytecode of the Example class, and loads it dynamically byte[] code = cw.toByteArray(); FileOutputStream fos = new FileOutputStream("Example.class"); fos.write(code); fos.close(); Helloworld loader = new Helloworld(); Class exampleClass = loader.defineClass("Example", code, 0, code.length); // uses the dynamically generated class to print 'Helloworld' Method main = exampleClass.getMethods()[0]; main.invoke(null, new Object[] {null}); } } asm-1.5.3/examples/xml/annotate.xsl100644 0 0 11572 10033740602 14427 0ustar 0 0 Incoming calls: Line: try start try end catch () asm-1.5.3/examples/xml/copy.xsl100644 0 0 4044 10033740602 13544 0ustar 0 0 asm-1.5.3/examples/xml/linenumbers.xsl100644 0 0 6053 10033740602 15117 0ustar 0 0 Line: asm-1.5.3/examples/xml/profile.xsl100644 0 0 7652 10033740602 14242 0ustar 0 0 asm-1.5.3/examples/xml/readme.txt100644 0 0 1554 10034426266 14053 0ustar 0 0 This directory contains sample XSL transformation templates that demonstrate features of org.objectweb.asm.xml package. copy.xsl Copying source document into target without changes. strip.xsl Strips all attribute values from the target XML. Result document can't be used to generate bytecode. annotate.xsl Adds comments for labels and variable instructions to the target XML document. linenumbers.xsl Adds code to dump source line numbers for the executing code to System.err profile.xsl Adds code to dump execution time for each method to System.err You can use the following command to transform java -jar asm-xml.jar -in -out -xslt