http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Printer.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Printer.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Printer.java index a849298..2dd644a 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Printer.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Printer.java @@ -53,14 +53,14 @@ public abstract class Printer { /** * The names of the for <code>operand</code> parameter values of the - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitIntInsn} method when + * {@link org.objectweb.asm.MethodVisitor#visitIntInsn} method when * <code>opcode</code> is <code>NEWARRAY</code>. */ public static final String[] TYPES; /** * The names of the <code>tag</code> field values for - * {@link org.apache.tapestry5.internal.plastic.asm.Handle}. + * {@link org.objectweb.asm.Handle}. */ public static final String[] HANDLE_TAG; @@ -117,7 +117,7 @@ public abstract class Printer { /** * The ASM API version implemented by this class. The value of this field - * must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}. + * must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. */ protected final int api; @@ -142,6 +142,10 @@ public abstract class Printer { /** * Constructs a new {@link Printer}. + * + * @param api + * the ASM API version implemented by this printer. Must be one + * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. */ protected Printer(final int api) { this.api = api; @@ -150,34 +154,121 @@ public abstract class Printer { } /** - * Class header. See {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visit}. + * Class header. + * See {@link org.objectweb.asm.ClassVisitor#visit}. + * + * @param version + * the class version. + * @param access + * the class's access flags (see {@link Opcodes}). This parameter + * also indicates if the class is deprecated. + * @param name + * the internal name of the class (see + * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). + * @param signature + * the signature of this class. May be <tt>null</tt> if the class + * is not a generic one, and does not extend or implement generic + * classes or interfaces. + * @param superName + * the internal of name of the super class (see + * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). + * For interfaces, the super class is {@link Object}. May be + * <tt>null</tt>, but only for the {@link Object} class. + * @param interfaces + * the internal names of the class's interfaces (see + * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). + * May be <tt>null</tt>. */ public abstract void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces); /** - * Class source. See {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visitSource}. + * Class source. + * See {@link org.objectweb.asm.ClassVisitor#visitSource}. + * + * @param source + * the name of the source file from which the class was compiled. + * May be <tt>null</tt>. + * @param debug + * additional debug information to compute the correspondance + * between source and compiled elements of the class. May be + * <tt>null</tt>. */ - public abstract void visitSource(final String file, final String debug); + public abstract void visitSource(final String source, final String debug); + /** - * Class outer class. See - * {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visitOuterClass}. + * Module. + * See {@link org.objectweb.asm.ClassVisitor#visitModule(String, int)}. + * + * @param name + * module name. + * @param access + * module flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} + * and {@code ACC_MANDATED}. + * @param version + * module version or null. + * @return + */ + public Printer visitModule(String name, int access, String version) { + throw new RuntimeException("Must be overriden"); + } + + /** + * Class outer class. + * See {@link org.objectweb.asm.ClassVisitor#visitOuterClass}. + * + * Visits the enclosing class of the class. This method must be called only + * if the class has an enclosing class. + * + * @param owner + * internal name of the enclosing class of the class. + * @param name + * the name of the method that contains the class, or + * <tt>null</tt> if the class is not enclosed in a method of its + * enclosing class. + * @param desc + * the descriptor of the method that contains the class, or + * <tt>null</tt> if the class is not enclosed in a method of its + * enclosing class. */ public abstract void visitOuterClass(final String owner, final String name, final String desc); /** - * Class annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visitAnnotation}. + * Class annotation. + * See {@link org.objectweb.asm.ClassVisitor#visitAnnotation}. + * + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public abstract Printer visitClassAnnotation(final String desc, final boolean visible); /** - * Class type annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visitTypeAnnotation}. + * Class type annotation. + * See {@link org.objectweb.asm.ClassVisitor#visitTypeAnnotation}. + * + * @param typeRef + * a reference to the annotated type. The sort of this type + * reference must be + * {@link org.objectweb.asm.TypeReference#CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER}, + * {@link org.objectweb.asm.TypeReference#CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} + * or {@link org.objectweb.asm.TypeReference#CLASS_EXTENDS CLASS_EXTENDS}. + * See {@link org.objectweb.asm.TypeReference}. + * @param typePath + * the path to the annotated type argument, wildcard bound, array + * element type, or static inner type within 'typeRef'. May be + * <tt>null</tt> if the annotation targets 'typeRef' as a whole. + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public Printer visitClassTypeAnnotation(final int typeRef, final TypePath typePath, final String desc, final boolean visible) { @@ -185,65 +276,201 @@ public abstract class Printer { } /** - * Class attribute. See - * {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visitAttribute}. + * Class attribute. + * See {@link org.objectweb.asm.ClassVisitor#visitAttribute}. + * + * @param attr + * an attribute. */ public abstract void visitClassAttribute(final Attribute attr); /** - * Class inner name. See - * {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visitInnerClass}. + * Class inner name. + * See {@link org.objectweb.asm.ClassVisitor#visitInnerClass}. + * + * @param name + * the internal name of an inner class (see + * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). + * @param outerName + * the internal name of the class to which the inner class + * belongs (see {@link org.objectweb.asm.Type#getInternalName() getInternalName}). + * May be <tt>null</tt> for not member classes. + * @param innerName + * the (simple) name of the inner class inside its enclosing + * class. May be <tt>null</tt> for anonymous inner classes. + * @param access + * the access flags of the inner class as originally declared in + * the enclosing class. */ public abstract void visitInnerClass(final String name, final String outerName, final String innerName, final int access); /** - * Class field. See {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visitField}. + * Class field. + * See {@link org.objectweb.asm.ClassVisitor#visitField}. + * + * @param access + * the field's access flags (see {@link Opcodes}). This parameter + * also indicates if the field is synthetic and/or deprecated. + * @param name + * the field's name. + * @param desc + * the field's descriptor (see {@link org.objectweb.asm.Type Type}). + * @param signature + * the field's signature. May be <tt>null</tt> if the field's + * type does not use generic types. + * @param value + * the field's initial value. This parameter, which may be + * <tt>null</tt> if the field does not have an initial value, + * must be an {@link Integer}, a {@link Float}, a {@link Long}, a + * {@link Double} or a {@link String} (for <tt>int</tt>, + * <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields + * respectively). <i>This parameter is only used for static + * fields</i>. Its value is ignored for non static fields, which + * must be initialized through bytecode instructions in + * constructors or methods. + * @return the printer */ public abstract Printer visitField(final int access, final String name, final String desc, final String signature, final Object value); /** - * Class method. See {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visitMethod}. + * Class method. + * See {@link org.objectweb.asm.ClassVisitor#visitMethod}. + * + * @param access + * the method's access flags (see {@link Opcodes}). This + * parameter also indicates if the method is synthetic and/or + * deprecated. + * @param name + * the method's name. + * @param desc + * the method's descriptor (see {@link org.objectweb.asm.Type Type}). + * @param signature + * the method's signature. May be <tt>null</tt> if the method + * parameters, return type and exceptions do not use generic + * types. + * @param exceptions + * the internal names of the method's exception classes (see + * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). May be + * <tt>null</tt>. + * @return the printer */ public abstract Printer visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions); /** - * Class end. See {@link org.apache.tapestry5.internal.plastic.asm.ClassVisitor#visitEnd}. + * Class end. See {@link org.objectweb.asm.ClassVisitor#visitEnd}. */ public abstract void visitClassEnd(); // ------------------------------------------------------------------------ + // Module + // ------------------------------------------------------------------------ + + public void visitMainClass(String mainClass) { + throw new RuntimeException("Must be overriden"); + } + + public void visitPackage(String packaze) { + throw new RuntimeException("Must be overriden"); + } + + public void visitRequire(String module, int access, String version) { + throw new RuntimeException("Must be overriden"); + } + + public void visitExport(String packaze, int access, String... modules) { + throw new RuntimeException("Must be overriden"); + } + + public void visitOpen(String packaze, int access, String... modules) { + throw new RuntimeException("Must be overriden"); + } + + public void visitUse(String service) { + throw new RuntimeException("Must be overriden"); + } + + public void visitProvide(String service, String... providers) { + throw new RuntimeException("Must be overriden"); + } + + /** + * Module end. See {@link org.objectweb.asm.ModuleVisitor#visitEnd}. + */ + public void visitModuleEnd() { + throw new RuntimeException("Must be overriden"); + } + + // ------------------------------------------------------------------------ // Annotations // ------------------------------------------------------------------------ /** - * Annotation value. See {@link org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor#visit}. + * Annotation value. + * See {@link org.objectweb.asm.AnnotationVisitor#visit}. + * + * @param name + * the value name. + * @param value + * the actual value, whose type must be {@link Byte}, + * {@link Boolean}, {@link Character}, {@link Short}, + * {@link Integer} , {@link Long}, {@link Float}, {@link Double}, + * {@link String} or {@link org.objectweb.asm.Type} + * or OBJECT or ARRAY sort. + * This value can also be an array of byte, boolean, short, char, int, + * long, float or double values (this is equivalent to using + * {@link #visitArray visitArray} and visiting each array element + * in turn, but is more convenient). */ public abstract void visit(final String name, final Object value); /** - * Annotation enum value. See - * {@link org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor#visitEnum}. + * Annotation enum value. + * See {@link org.objectweb.asm.AnnotationVisitor#visitEnum}. + * + * Visits an enumeration value of the annotation. + * + * @param name + * the value name. + * @param desc + * the class descriptor of the enumeration class. + * @param value + * the actual enumeration value. */ public abstract void visitEnum(final String name, final String desc, final String value); /** - * Nested annotation value. See - * {@link org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor#visitAnnotation}. + * Nested annotation value. + * See {@link org.objectweb.asm.AnnotationVisitor#visitAnnotation}. + * + * @param name + * the value name. + * @param desc + * the class descriptor of the nested annotation class. + * @return the printer */ public abstract Printer visitAnnotation(final String name, final String desc); /** - * Annotation array value. See - * {@link org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor#visitArray}. + * Annotation array value. + * See {@link org.objectweb.asm.AnnotationVisitor#visitArray}. + * + * Visits an array value of the annotation. Note that arrays of primitive + * types (such as byte, boolean, short, char, int, long, float or double) + * can be passed as value to {@link #visit visit}. This is what + * {@link org.objectweb.asm.ClassReader} does. + * + * @param name + * the value name. + * @return the printer */ public abstract Printer visitArray(final String name); /** - * Annotation end. See {@link org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor#visitEnd}. + * Annotation end. See {@link org.objectweb.asm.AnnotationVisitor#visitEnd}. */ public abstract void visitAnnotationEnd(); @@ -252,15 +479,35 @@ public abstract class Printer { // ------------------------------------------------------------------------ /** - * Field annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.FieldVisitor#visitAnnotation}. + * Field annotation. + * See {@link org.objectweb.asm.FieldVisitor#visitAnnotation}. + * + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public abstract Printer visitFieldAnnotation(final String desc, final boolean visible); /** - * Field type annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.FieldVisitor#visitTypeAnnotation}. + * Field type annotation. + * See {@link org.objectweb.asm.FieldVisitor#visitTypeAnnotation}. + * + * @param typeRef + * a reference to the annotated type. The sort of this type + * reference must be {@link org.objectweb.asm.TypeReference#FIELD FIELD}. + * See {@link org.objectweb.asm.TypeReference}. + * @param typePath + * the path to the annotated type argument, wildcard bound, array + * element type, or static inner type within 'typeRef'. May be + * <tt>null</tt> if the annotation targets 'typeRef' as a whole. + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public Printer visitFieldTypeAnnotation(final int typeRef, final TypePath typePath, final String desc, final boolean visible) { @@ -268,13 +515,17 @@ public abstract class Printer { } /** - * Field attribute. See - * {@link org.apache.tapestry5.internal.plastic.asm.FieldVisitor#visitAttribute}. + * Field attribute. + * See {@link org.objectweb.asm.FieldVisitor#visitAttribute}. + * + * @param attr + * an attribute. */ public abstract void visitFieldAttribute(final Attribute attr); /** - * Field end. See {@link org.apache.tapestry5.internal.plastic.asm.FieldVisitor#visitEnd}. + * Field end. + * See {@link org.objectweb.asm.FieldVisitor#visitEnd}. */ public abstract void visitFieldEnd(); @@ -283,29 +534,58 @@ public abstract class Printer { // ------------------------------------------------------------------------ /** - * Method parameter. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitParameter(String, int)}. + * Method parameter. + * See {@link org.objectweb.asm.MethodVisitor#visitParameter(String, int)}. + * + * @param name + * parameter name or null if none is provided. + * @param access + * the parameter's access flags, only <tt>ACC_FINAL</tt>, + * <tt>ACC_SYNTHETIC</tt> or/and <tt>ACC_MANDATED</tt> are + * allowed (see {@link Opcodes}). */ public void visitParameter(String name, int access) { throw new RuntimeException("Must be overriden"); } /** - * Method default annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitAnnotationDefault}. + * Method default annotation. + * See {@link org.objectweb.asm.MethodVisitor#visitAnnotationDefault}. + * + * @return the printer */ public abstract Printer visitAnnotationDefault(); /** - * Method annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitAnnotation}. + * Method annotation. + * See {@link org.objectweb.asm.MethodVisitor#visitAnnotation}. + * + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public abstract Printer visitMethodAnnotation(final String desc, final boolean visible); /** - * Method type annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitTypeAnnotation}. + * Method type annotation. + * See {@link org.objectweb.asm.MethodVisitor#visitTypeAnnotation}. + * + * @param typeRef + * a reference to the annotated type. The sort of this type + * reference must be {@link org.objectweb.asm.TypeReference#FIELD FIELD}. + * See {@link org.objectweb.asm.TypeReference}. + * @param typePath + * the path to the annotated type argument, wildcard bound, array + * element type, or static inner type within 'typeRef'. May be + * <tt>null</tt> if the annotation targets 'typeRef' as a whole. + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public Printer visitMethodTypeAnnotation(final int typeRef, final TypePath typePath, final String desc, final boolean visible) { @@ -313,64 +593,225 @@ public abstract class Printer { } /** - * Method parameter annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitParameterAnnotation}. + * Method parameter annotation. + * See {@link org.objectweb.asm.MethodVisitor#visitParameterAnnotation}. + * + * @param parameter + * the parameter index. + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public abstract Printer visitParameterAnnotation(final int parameter, final String desc, final boolean visible); /** - * Method attribute. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitAttribute}. + * Method attribute. + * See {@link org.objectweb.asm.MethodVisitor#visitAttribute}. + * + * @param attr + * an attribute. */ public abstract void visitMethodAttribute(final Attribute attr); /** - * Method start. See {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitCode}. + * Method start. + * See {@link org.objectweb.asm.MethodVisitor#visitCode}. */ public abstract void visitCode(); /** - * Method stack frame. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitFrame}. + * Method stack frame. + * See {@link org.objectweb.asm.MethodVisitor#visitFrame}. + * + * Visits the current state of the local variables and operand stack + * elements. This method must(*) be called <i>just before</i> any + * instruction <b>i</b> that follows an unconditional branch instruction + * such as GOTO or THROW, that is the target of a jump instruction, or that + * starts an exception handler block. The visited types must describe the + * values of the local variables and of the operand stack elements <i>just + * before</i> <b>i</b> is executed.<br> + * <br> + * (*) this is mandatory only for classes whose version is greater than or + * equal to {@link Opcodes#V1_6 V1_6}. <br> + * <br> + * The frames of a method must be given either in expanded form, or in + * compressed form (all frames must use the same format, i.e. you must not + * mix expanded and compressed frames within a single method): + * <ul> + * <li>In expanded form, all frames must have the F_NEW type.</li> + * <li>In compressed form, frames are basically "deltas" from the state of + * the previous frame: + * <ul> + * <li>{@link Opcodes#F_SAME} representing frame with exactly the same + * locals as the previous frame and with the empty stack.</li> + * <li>{@link Opcodes#F_SAME1} representing frame with exactly the same + * locals as the previous frame and with single value on the stack ( + * <code>nStack</code> is 1 and <code>stack[0]</code> contains value for the + * type of the stack item).</li> + * <li>{@link Opcodes#F_APPEND} representing frame with current locals are + * the same as the locals in the previous frame, except that additional + * locals are defined (<code>nLocal</code> is 1, 2 or 3 and + * <code>local</code> elements contains values representing added types).</li> + * <li>{@link Opcodes#F_CHOP} representing frame with current locals are the + * same as the locals in the previous frame, except that the last 1-3 locals + * are absent and with the empty stack (<code>nLocals</code> is 1, 2 or 3).</li> + * <li>{@link Opcodes#F_FULL} representing complete frame data.</li> + * </ul> + * </li> + * </ul> + * <br> + * In both cases the first frame, corresponding to the method's parameters + * and access flags, is implicit and must not be visited. Also, it is + * illegal to visit two or more frames for the same code location (i.e., at + * least one instruction must be visited between two calls to visitFrame). + * + * @param type + * the type of this stack map frame. Must be + * {@link Opcodes#F_NEW} for expanded frames, or + * {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND}, + * {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or + * {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for + * compressed frames. + * @param nLocal + * the number of local variables in the visited frame. + * @param local + * the local variable types in this frame. This array must not be + * modified. Primitive types are represented by + * {@link Opcodes#TOP}, {@link Opcodes#INTEGER}, + * {@link Opcodes#FLOAT}, {@link Opcodes#LONG}, + * {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or + * {@link Opcodes#UNINITIALIZED_THIS} (long and double are + * represented by a single element). Reference types are + * represented by String objects (representing internal names), + * and uninitialized types by Label objects (this label + * designates the NEW instruction that created this uninitialized + * value). + * @param nStack + * the number of operand stack elements in the visited frame. + * @param stack + * the operand stack types in this frame. This array must not be + * modified. Its content has the same format as the "local" + * array. + * @throws IllegalStateException + * if a frame is visited just after another one, without any + * instruction between the two (unless this frame is a + * Opcodes#F_SAME frame, in which case it is silently ignored). */ public abstract void visitFrame(final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack); /** - * Method instruction. See {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitInsn} - * . + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitInsn} + * + * @param opcode + * the opcode of the instruction to be visited. This opcode is + * either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, + * ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, + * FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD, + * LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, + * IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, + * SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, + * DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, + * IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, + * FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, + * IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D, + * L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S, + * LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, FRETURN, + * DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER, + * or MONITOREXIT. */ public abstract void visitInsn(final int opcode); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitIntInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitIntInsn}. + * + * @param opcode + * the opcode of the instruction to be visited. This opcode is + * either BIPUSH, SIPUSH or NEWARRAY. + * @param operand + * the operand of the instruction to be visited.<br> + * When opcode is BIPUSH, operand value should be between + * Byte.MIN_VALUE and Byte.MAX_VALUE.<br> + * When opcode is SIPUSH, operand value should be between + * Short.MIN_VALUE and Short.MAX_VALUE.<br> + * When opcode is NEWARRAY, operand value should be one of + * {@link Opcodes#T_BOOLEAN}, {@link Opcodes#T_CHAR}, + * {@link Opcodes#T_FLOAT}, {@link Opcodes#T_DOUBLE}, + * {@link Opcodes#T_BYTE}, {@link Opcodes#T_SHORT}, + * {@link Opcodes#T_INT} or {@link Opcodes#T_LONG}. */ public abstract void visitIntInsn(final int opcode, final int operand); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitVarInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitVarInsn}. + * + * @param opcode + * the opcode of the local variable instruction to be visited. + * This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, + * ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET. + * @param var + * the operand of the instruction to be visited. This operand is + * the index of a local variable. */ public abstract void visitVarInsn(final int opcode, final int var); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitTypeInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitTypeInsn}. + * + /** + * Visits a type instruction. A type instruction is an instruction that + * takes the internal name of a class as parameter. + * + * @param opcode + * the opcode of the type instruction to be visited. This opcode + * is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF. + * @param type + * the operand of the instruction to be visited. This operand + * must be the internal name of an object or array class (see + * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). */ public abstract void visitTypeInsn(final int opcode, final String type); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitFieldInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitFieldInsn}. + * + * @param opcode + * the opcode of the type instruction to be visited. This opcode + * is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD. + * @param owner + * the internal name of the field's owner class (see + * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). + * @param name + * the field's name. + * @param desc + * the field's descriptor (see {@link org.objectweb.asm.Type Type}). */ public abstract void visitFieldInsn(final int opcode, final String owner, final String name, final String desc); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitMethodInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitMethodInsn}. + * + * @param opcode + * the opcode of the type instruction to be visited. This opcode + * is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or + * INVOKEINTERFACE. + * @param owner + * the internal name of the method's owner class (see + * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). + * @param name + * the method's name. + * @param desc + * the method's descriptor (see {@link org.objectweb.asm.Type Type}). */ @Deprecated public void visitMethodInsn(final int opcode, final String owner, @@ -384,8 +825,22 @@ public abstract class Printer { } /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitMethodInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitMethodInsn}. + * + * @param opcode + * the opcode of the type instruction to be visited. This opcode + * is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or + * INVOKEINTERFACE. + * @param owner + * the internal name of the method's owner class (see + * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). + * @param name + * the method's name. + * @param desc + * the method's descriptor (see {@link org.objectweb.asm.Type Type}). + * @param itf + * if the method's owner class is an interface. */ public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc, final boolean itf) { @@ -401,59 +856,181 @@ public abstract class Printer { } /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitInvokeDynamicInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitInvokeDynamicInsn}. + * + * Visits an invokedynamic instruction. + * + * @param name + * the method's name. + * @param desc + * the method's descriptor (see {@link org.objectweb.asm.Type Type}). + * @param bsm + * the bootstrap method. + * @param bsmArgs + * the bootstrap method constant arguments. Each argument must be + * an {@link Integer}, {@link Float}, {@link Long}, + * {@link Double}, {@link String}, {@link org.objectweb.asm.Type} or {@link Handle} + * value. This method is allowed to modify the content of the + * array so a caller should expect that this array may change. */ public abstract void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitJumpInsn}. + * Method jump instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitJumpInsn}. + * + * @param opcode + * the opcode of the type instruction to be visited. This opcode + * is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, + * IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, + * IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL. + * @param label + * the operand of the instruction to be visited. This operand is + * a label that designates the instruction to which the jump + * instruction may jump. */ public abstract void visitJumpInsn(final int opcode, final Label label); /** - * Method label. See {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitLabel}. + * Method label. + * See {@link org.objectweb.asm.MethodVisitor#visitLabel}. + * + * @param label + * a {@link Label Label} object. */ public abstract void visitLabel(final Label label); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitLdcInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitLdcInsn}. + * + * Visits a LDC instruction. Note that new constant types may be added in + * future versions of the Java Virtual Machine. To easily detect new + * constant types, implementations of this method should check for + * unexpected constant types, like this: + * + * <pre> + * if (cst instanceof Integer) { + * // ... + * } else if (cst instanceof Float) { + * // ... + * } else if (cst instanceof Long) { + * // ... + * } else if (cst instanceof Double) { + * // ... + * } else if (cst instanceof String) { + * // ... + * } else if (cst instanceof Type) { + * int sort = ((Type) cst).getSort(); + * if (sort == Type.OBJECT) { + * // ... + * } else if (sort == Type.ARRAY) { + * // ... + * } else if (sort == Type.METHOD) { + * // ... + * } else { + * // throw an exception + * } + * } else if (cst instanceof Handle) { + * // ... + * } else { + * // throw an exception + * } + * </pre> + * + * @param cst + * the constant to be loaded on the stack. This parameter must be + * a non null {@link Integer}, a {@link Float}, a {@link Long}, a + * {@link Double}, a {@link String}, a {@link org.objectweb.asm.Type} + * of OBJECT or ARRAY sort for <tt>.class</tt> constants, for classes whose + * version is 49.0, a {@link org.objectweb.asm.Type} of METHOD sort or a + * {@link Handle} for MethodType and MethodHandle constants, for + * classes whose version is 51.0. */ public abstract void visitLdcInsn(final Object cst); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitIincInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitIincInsn}. + * + * @param var + * index of the local variable to be incremented. + * @param increment + * amount to increment the local variable by. */ public abstract void visitIincInsn(final int var, final int increment); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitTableSwitchInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitTableSwitchInsn}. + * + * @param min + * the minimum key value. + * @param max + * the maximum key value. + * @param dflt + * beginning of the default handler block. + * @param labels + * beginnings of the handler blocks. <tt>labels[i]</tt> is the + * beginning of the handler block for the <tt>min + i</tt> key. */ public abstract void visitTableSwitchInsn(final int min, final int max, final Label dflt, final Label... labels); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitLookupSwitchInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitLookupSwitchInsn}. + * + * @param dflt + * beginning of the default handler block. + * @param keys + * the values of the keys. + * @param labels + * beginnings of the handler blocks. <tt>labels[i]</tt> is the + * beginning of the handler block for the <tt>keys[i]</tt> key. */ public abstract void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels); /** - * Method instruction. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitMultiANewArrayInsn}. + * Method instruction. + * See {@link org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn}. + * + * @param desc + * an array type descriptor (see {@link org.objectweb.asm.Type Type}). + * @param dims + * number of dimensions of the array to allocate. */ public abstract void visitMultiANewArrayInsn(final String desc, final int dims); /** - * Instruction type annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitInsnAnnotation}. + * Instruction type annotation. + * See {@link org.objectweb.asm.MethodVisitor#visitInsnAnnotation}. + * + * @param typeRef + * a reference to the annotated type. The sort of this type + * reference must be {@link org.objectweb.asm.TypeReference#INSTANCEOF INSTANCEOF}, + * {@link org.objectweb.asm.TypeReference#NEW NEW}, + * {@link org.objectweb.asm.TypeReference#CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE}, + * {@link org.objectweb.asm.TypeReference#METHOD_REFERENCE METHOD_REFERENCE}, + * {@link org.objectweb.asm.TypeReference#CAST CAST}, + * {@link org.objectweb.asm.TypeReference#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, + * {@link org.objectweb.asm.TypeReference#METHOD_INVOCATION_TYPE_ARGUMENT METHOD_INVOCATION_TYPE_ARGUMENT}, + * {@link org.objectweb.asm.TypeReference#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, + * or {@link org.objectweb.asm.TypeReference#METHOD_REFERENCE_TYPE_ARGUMENT METHOD_REFERENCE_TYPE_ARGUMENT}. + * See {@link org.objectweb.asm.TypeReference}. + * @param typePath + * the path to the annotated type argument, wildcard bound, array + * element type, or static inner type within 'typeRef'. May be + * <tt>null</tt> if the annotation targets 'typeRef' as a whole. + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public Printer visitInsnAnnotation(final int typeRef, final TypePath typePath, final String desc, final boolean visible) { @@ -461,15 +1038,44 @@ public abstract class Printer { } /** - * Method exception handler. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitTryCatchBlock}. + * Method exception handler. + * See {@link org.objectweb.asm.MethodVisitor#visitTryCatchBlock}. + * + * @param start + * beginning of the exception handler's scope (inclusive). + * @param end + * end of the exception handler's scope (exclusive). + * @param handler + * beginning of the exception handler's code. + * @param type + * internal name of the type of exceptions handled by the + * handler, or <tt>null</tt> to catch any exceptions (for + * "finally" blocks). + * @throws IllegalArgumentException + * if one of the labels has already been visited by this visitor + * (by the {@link #visitLabel visitLabel} method). */ public abstract void visitTryCatchBlock(final Label start, final Label end, final Label handler, final String type); /** - * Try catch block type annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitTryCatchAnnotation}. + * Try catch block type annotation. + * See {@link org.objectweb.asm.MethodVisitor#visitTryCatchAnnotation}. + * + * @param typeRef + * a reference to the annotated type. The sort of this type + * reference must be {@link org.objectweb.asm.TypeReference#EXCEPTION_PARAMETER + * EXCEPTION_PARAMETER}. + * See {@link org.objectweb.asm.TypeReference}. + * @param typePath + * the path to the annotated type argument, wildcard bound, array + * element type, or static inner type within 'typeRef'. May be + * <tt>null</tt> if the annotation targets 'typeRef' as a whole. + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public Printer visitTryCatchAnnotation(final int typeRef, final TypePath typePath, final String desc, final boolean visible) { @@ -477,16 +1083,62 @@ public abstract class Printer { } /** - * Method debug info. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitLocalVariable}. + * Method debug info. + * See {@link org.objectweb.asm.MethodVisitor#visitLocalVariable}. + * + * @param name + * the name of a local variable. + * @param desc + * the type descriptor of this local variable. + * @param signature + * the type signature of this local variable. May be + * <tt>null</tt> if the local variable type does not use generic + * types. + * @param start + * the first instruction corresponding to the scope of this local + * variable (inclusive). + * @param end + * the last instruction corresponding to the scope of this local + * variable (exclusive). + * @param index + * the local variable's index. + * @throws IllegalArgumentException + * if one of the labels has not already been visited by this + * visitor (by the {@link #visitLabel visitLabel} method). */ public abstract void visitLocalVariable(final String name, final String desc, final String signature, final Label start, final Label end, final int index); /** - * Local variable type annotation. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitTryCatchAnnotation}. + * Local variable type annotation. + * See {@link org.objectweb.asm.MethodVisitor#visitTryCatchAnnotation}. + * + * @param typeRef + * a reference to the annotated type. The sort of this type + * reference must be {@link org.objectweb.asm.TypeReference#LOCAL_VARIABLE + * LOCAL_VARIABLE} or {@link org.objectweb.asm.TypeReference#RESOURCE_VARIABLE + * RESOURCE_VARIABLE}. + * See {@link org.objectweb.asm.TypeReference}. + * @param typePath + * the path to the annotated type argument, wildcard bound, array + * element type, or static inner type within 'typeRef'. May be + * <tt>null</tt> if the annotation targets 'typeRef' as a whole. + * @param start + * the fist instructions corresponding to the continuous ranges + * that make the scope of this local variable (inclusive). + * @param end + * the last instructions corresponding to the continuous ranges + * that make the scope of this local variable (exclusive). This + * array must have the same size as the 'start' array. + * @param index + * the local variable's index in each range. This array must have + * the same size as the 'start' array. + * @param desc + * the class descriptor of the annotation class. + * @param visible + * <tt>true</tt> if the annotation is visible at runtime. + * @return the printer */ public Printer visitLocalVariableAnnotation(final int typeRef, final TypePath typePath, final Label[] start, final Label[] end, @@ -495,19 +1147,34 @@ public abstract class Printer { } /** - * Method debug info. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitLineNumber}. + * Method debug info. + * See {@link org.objectweb.asm.MethodVisitor#visitLineNumber}. + * + * @param line + * a line number. This number refers to the source file from + * which the class was compiled. + * @param start + * the first instruction corresponding to this line number. + * @throws IllegalArgumentException + * if <tt>start</tt> has not already been visited by this + * visitor (by the {@link #visitLabel visitLabel} method). */ public abstract void visitLineNumber(final int line, final Label start); /** - * Method max stack and max locals. See - * {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitMaxs}. + * Method max stack and max locals. + * See {@link org.objectweb.asm.MethodVisitor#visitMaxs}. + * + * @param maxStack + * maximum stack size of the method. + * @param maxLocals + * maximum number of local variables for the method. */ public abstract void visitMaxs(final int maxStack, final int maxLocals); /** - * Method end. See {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor#visitEnd}. + * Method end. + * See {@link org.objectweb.asm.MethodVisitor#visitEnd}. */ public abstract void visitMethodEnd(); @@ -586,4 +1253,4 @@ public abstract class Printer { } } } -} +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifiable.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifiable.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifiable.java index dfa5e41..fa5e1da 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifiable.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifiable.java @@ -34,7 +34,7 @@ import java.util.Map; import org.apache.tapestry5.internal.plastic.asm.Label; /** - * An {@link org.apache.tapestry5.internal.plastic.asm.Attribute Attribute} that can print a readable + * An {@link org.objectweb.asm.Attribute Attribute} that can print a readable * representation of itself. * * Implementations should construct readable output from an attribute data http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifier.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifier.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifier.java index 27227e27..448728a 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifier.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/Textifier.java @@ -29,14 +29,21 @@ */ package org.apache.tapestry5.internal.plastic.asm.util; -import org.apache.tapestry5.internal.plastic.asm.*; -import org.apache.tapestry5.internal.plastic.asm.signature.SignatureReader; - import java.io.FileInputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; +import org.apache.tapestry5.internal.plastic.asm.Attribute; +import org.apache.tapestry5.internal.plastic.asm.ClassReader; +import org.apache.tapestry5.internal.plastic.asm.Handle; +import org.apache.tapestry5.internal.plastic.asm.Label; +import org.apache.tapestry5.internal.plastic.asm.Opcodes; +import org.apache.tapestry5.internal.plastic.asm.Type; +import org.apache.tapestry5.internal.plastic.asm.TypePath; +import org.apache.tapestry5.internal.plastic.asm.TypeReference; +import org.apache.tapestry5.internal.plastic.asm.signature.SignatureReader; + /** * A {@link Printer} that prints a disassembled view of the classes it visits. * @@ -146,7 +153,7 @@ public class Textifier extends Printer { * If a subclass calls this constructor. */ public Textifier() { - this(Opcodes.ASM5); + this(Opcodes.ASM6); if (getClass() != Textifier.class) { throw new IllegalStateException(); } @@ -157,7 +164,7 @@ public class Textifier extends Printer { * * @param api * the ASM API version implemented by this visitor. Must be one - * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}. + * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. */ protected Textifier(final int api) { super(api); @@ -165,7 +172,7 @@ public class Textifier extends Printer { /** * Prints a disassembled view of the given class to the standard output. - * + * <p> * Usage: Textifier [-debug] <binary class name or class file name > * * @param args @@ -214,6 +221,10 @@ public class Textifier extends Printer { public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { + if ((access & Opcodes.ACC_MODULE) != 0) { + // visitModule will print the module + return; + } this.access = access; int major = version & 0xFFFF; int minor = version >>> 16; @@ -235,7 +246,7 @@ public class Textifier extends Printer { .append(sv.getDeclaration()).append('\n'); } - appendAccess(access & ~Opcodes.ACC_SUPER); + appendAccess(access & ~(Opcodes.ACC_SUPER | Opcodes.ACC_MODULE)); if ((access & Opcodes.ACC_ANNOTATION) != 0) { buf.append("@interface "); } else if ((access & Opcodes.ACC_INTERFACE) != 0) { @@ -277,6 +288,24 @@ public class Textifier extends Printer { text.add(buf.toString()); } } + + @Override + public Printer visitModule(final String name, final int access, + final String version) { + buf.setLength(0); + if ((access & Opcodes.ACC_OPEN) != 0) { + buf.append("open "); + } + buf.append("module ") + .append(name) + .append(" { ") + .append(version == null ? "" : "// " + version) + .append("\n\n"); + text.add(buf.toString()); + Textifier t = createTextifier(); + text.add(t.getText()); + return t; + } @Override public void visitOuterClass(final String owner, final String name, @@ -407,7 +436,7 @@ public class Textifier extends Printer { } buf.append(tab); - appendAccess(access & ~Opcodes.ACC_VOLATILE); + appendAccess(access & ~(Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT)); if ((access & Opcodes.ACC_NATIVE) != 0) { buf.append("native "); } @@ -447,6 +476,118 @@ public class Textifier extends Printer { } // ------------------------------------------------------------------------ + // Module + // ------------------------------------------------------------------------ + + @Override + public void visitMainClass(String mainClass) { + buf.setLength(0); + buf.append(" // main class ").append(mainClass).append('\n'); + text.add(buf.toString()); + } + + @Override + public void visitPackage(String packaze) { + buf.setLength(0); + buf.append(" // package ").append(packaze).append('\n'); + text.add(buf.toString()); + } + + @Override + public void visitRequire(String require, int access, String version) { + buf.setLength(0); + buf.append(tab).append("requires "); + if ((access & Opcodes.ACC_TRANSITIVE) != 0) { + buf.append("transitive "); + } + if ((access & Opcodes.ACC_STATIC_PHASE) != 0) { + buf.append("static "); + } + buf.append(require) + .append("; // access flags 0x") + .append(Integer.toHexString(access).toUpperCase()) + .append('\n'); + if (version != null) { + buf.append(" // version ") + .append(version) + .append('\n'); + } + text.add(buf.toString()); + } + + @Override + public void visitExport(String export, int access, String... modules) { + buf.setLength(0); + buf.append(tab).append("exports "); + buf.append(export); + if (modules != null && modules.length > 0) { + buf.append(" to"); + } else { + buf.append(';'); + } + buf.append(" // access flags 0x") + .append(Integer.toHexString(access).toUpperCase()) + .append('\n'); + if (modules != null && modules.length > 0) { + for (int i = 0; i < modules.length; ++i) { + buf.append(tab2).append(modules[i]); + buf.append(i != modules.length - 1 ? ",\n": ";\n"); + } + } + text.add(buf.toString()); + } + + @Override + public void visitOpen(String export, int access, String... modules) { + buf.setLength(0); + buf.append(tab).append("opens "); + buf.append(export); + if (modules != null && modules.length > 0) { + buf.append(" to"); + } else { + buf.append(';'); + } + buf.append(" // access flags 0x") + .append(Integer.toHexString(access).toUpperCase()) + .append('\n'); + if (modules != null && modules.length > 0) { + for (int i = 0; i < modules.length; ++i) { + buf.append(tab2).append(modules[i]); + buf.append(i != modules.length - 1 ? ",\n": ";\n"); + } + } + text.add(buf.toString()); + } + + @Override + public void visitUse(String use) { + buf.setLength(0); + buf.append(tab).append("uses "); + appendDescriptor(INTERNAL_NAME, use); + buf.append(";\n"); + text.add(buf.toString()); + } + + @Override + public void visitProvide(String provide, String... providers) { + buf.setLength(0); + buf.append(tab).append("provides "); + appendDescriptor(INTERNAL_NAME, provide); + buf.append(" with\n"); + for (int i = 0; i < providers.length; ++i) { + buf.append(tab2); + appendDescriptor(INTERNAL_NAME, providers[i]); + buf.append(i != providers.length - 1 ? ",\n": ";\n"); + } + text.add(buf.toString()); + } + + @Override + public void visitModuleEnd() { + // empty + } + + // ------------------------------------------------------------------------ // Annotations // ------------------------------------------------------------------------ @@ -1260,13 +1401,16 @@ public class Textifier extends Printer { appendDescriptor(INTERNAL_NAME, h.getOwner()); buf.append('.'); buf.append(h.getName()); - if(!isMethodHandle){ + if (!isMethodHandle) { buf.append('('); } appendDescriptor(HANDLE_DESCRIPTOR, h.getDesc()); - if(!isMethodHandle){ + if (!isMethodHandle) { buf.append(')'); } + if (h.isInterface()) { + buf.append(" itf"); + } } /** http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceAnnotationVisitor.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceAnnotationVisitor.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceAnnotationVisitor.java index 3af500a..dbccd3c 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceAnnotationVisitor.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceAnnotationVisitor.java @@ -47,7 +47,7 @@ public final class TraceAnnotationVisitor extends AnnotationVisitor { } public TraceAnnotationVisitor(final AnnotationVisitor av, final Printer p) { - super(Opcodes.ASM5, av); + super(Opcodes.ASM6, av); this.p = p; } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceClassVisitor.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceClassVisitor.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceClassVisitor.java index c6f79ac..95435fe 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceClassVisitor.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceClassVisitor.java @@ -29,18 +29,25 @@ */ package org.apache.tapestry5.internal.plastic.asm.util; -import org.apache.tapestry5.internal.plastic.asm.*; - import java.io.PrintWriter; +import org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor; +import org.apache.tapestry5.internal.plastic.asm.Attribute; +import org.apache.tapestry5.internal.plastic.asm.ClassVisitor; +import org.apache.tapestry5.internal.plastic.asm.FieldVisitor; +import org.apache.tapestry5.internal.plastic.asm.MethodVisitor; +import org.apache.tapestry5.internal.plastic.asm.ModuleVisitor; +import org.apache.tapestry5.internal.plastic.asm.Opcodes; +import org.apache.tapestry5.internal.plastic.asm.TypePath; + /** * A {@link ClassVisitor} that prints the classes it visits with a * {@link Printer}. This class visitor can be used in the middle of a class * visitor chain to trace the class that is visited at a given point in this * chain. This may be useful for debugging purposes. - * + * <p> * The trace printed when visiting the <tt>Hello</tt> class is the following: - * + * <p> * <blockquote> * * <pre> @@ -58,7 +65,7 @@ import java.io.PrintWriter; * </pre> * * </blockquote> where <tt>Hello</tt> is defined by: - * + * <p> * <blockquote> * * <pre> @@ -125,7 +132,7 @@ public final class TraceClassVisitor extends ClassVisitor { */ public TraceClassVisitor(final ClassVisitor cv, final Printer p, final PrintWriter pw) { - super(Opcodes.ASM5, cv); + super(Opcodes.ASM6, cv); this.pw = pw; this.p = p; } @@ -143,6 +150,14 @@ public final class TraceClassVisitor extends ClassVisitor { p.visitSource(file, debug); super.visitSource(file, debug); } + + @Override + public ModuleVisitor visitModule(String name, int flags, + String version) { + Printer p = this.p.visitModule(name, flags, version); + ModuleVisitor mv = super.visitModule(name, flags, version); + return new TraceModuleVisitor(mv, p); + } @Override public void visitOuterClass(final String owner, final String name, http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceFieldVisitor.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceFieldVisitor.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceFieldVisitor.java index 3fed39e..29b60b2 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceFieldVisitor.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceFieldVisitor.java @@ -50,7 +50,7 @@ public final class TraceFieldVisitor extends FieldVisitor { } public TraceFieldVisitor(final FieldVisitor fv, final Printer p) { - super(Opcodes.ASM5, fv); + super(Opcodes.ASM6, fv); this.p = p; } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceMethodVisitor.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceMethodVisitor.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceMethodVisitor.java index 859a8d1..053ff33 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceMethodVisitor.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceMethodVisitor.java @@ -52,7 +52,7 @@ public final class TraceMethodVisitor extends MethodVisitor { } public TraceMethodVisitor(final MethodVisitor mv, final Printer p) { - super(Opcodes.ASM5, mv); + super(Opcodes.ASM6, mv); this.p = p; } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceModuleVisitor.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceModuleVisitor.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceModuleVisitor.java new file mode 100644 index 0000000..94dc498 --- /dev/null +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceModuleVisitor.java @@ -0,0 +1,101 @@ +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 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. + */ +package org.apache.tapestry5.internal.plastic.asm.util; + +import org.apache.tapestry5.internal.plastic.asm.ModuleVisitor; +import org.apache.tapestry5.internal.plastic.asm.Opcodes; + +/** + * A {@link ModuleVisitor} that prints the fields it visits with a + * {@link Printer}. + * + * @author Remi Forax + */ +public final class TraceModuleVisitor extends ModuleVisitor { + + public final Printer p; + + public TraceModuleVisitor(final Printer p) { + this(null, p); + } + + public TraceModuleVisitor(final ModuleVisitor mv, final Printer p) { + super(Opcodes.ASM6, mv); + this.p = p; + } + + @Override + public void visitMainClass(String mainClass) { + p.visitMainClass(mainClass); + super.visitMainClass(mainClass); + } + + @Override + public void visitPackage(String packaze) { + p.visitPackage(packaze); + super.visitPackage(packaze); + } + + @Override + public void visitRequire(String module, int access, String version) { + p.visitRequire(module, access, version); + super.visitRequire(module, access, version); + } + + @Override + public void visitExport(String packaze, int access, String... modules) { + p.visitExport(packaze, access, modules); + super.visitExport(packaze, access, modules); + } + + @Override + public void visitOpen(String packaze, int access, String... modules) { + p.visitOpen(packaze, access, modules); + super.visitOpen(packaze, access, modules); + } + + @Override + public void visitUse(String use) { + p.visitUse(use); + super.visitUse(use); + } + + @Override + public void visitProvide(String service, String... providers) { + p.visitProvide(service, providers); + super.visitProvide(service, providers); + } + + @Override + public void visitEnd() { + p.visitModuleEnd(); + super.visitEnd(); + } +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceSignatureVisitor.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceSignatureVisitor.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceSignatureVisitor.java index 1e2c9a3..2125130 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceSignatureVisitor.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/util/TraceSignatureVisitor.java @@ -41,7 +41,7 @@ import org.apache.tapestry5.internal.plastic.asm.signature.SignatureVisitor; */ public final class TraceSignatureVisitor extends SignatureVisitor { - private final StringBuffer declaration; + private final StringBuilder declaration; private boolean isInterface; @@ -53,9 +53,9 @@ public final class TraceSignatureVisitor extends SignatureVisitor { private boolean seenInterface; - private StringBuffer returnType; + private StringBuilder returnType; - private StringBuffer exceptions; + private StringBuilder exceptions; /** * Stack used to keep track of class types that have arguments. Each element @@ -75,13 +75,13 @@ public final class TraceSignatureVisitor extends SignatureVisitor { private String separator = ""; public TraceSignatureVisitor(final int access) { - super(Opcodes.ASM5); + super(Opcodes.ASM6); isInterface = (access & Opcodes.ACC_INTERFACE) != 0; - this.declaration = new StringBuffer(); + this.declaration = new StringBuilder(); } - private TraceSignatureVisitor(final StringBuffer buf) { - super(Opcodes.ASM5); + private TraceSignatureVisitor(final StringBuilder buf) { + super(Opcodes.ASM6); this.declaration = buf; } @@ -146,14 +146,14 @@ public final class TraceSignatureVisitor extends SignatureVisitor { declaration.append('('); } declaration.append(')'); - returnType = new StringBuffer(); + returnType = new StringBuilder(); return new TraceSignatureVisitor(returnType); } @Override public SignatureVisitor visitExceptionType() { if (exceptions == null) { - exceptions = new StringBuffer(); + exceptions = new StringBuilder(); } else { exceptions.append(", "); } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/ASMContentHandler.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/ASMContentHandler.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/ASMContentHandler.java index 10f3a8f..3ebe653 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/ASMContentHandler.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/ASMContentHandler.java @@ -40,6 +40,7 @@ import org.apache.tapestry5.internal.plastic.asm.FieldVisitor; import org.apache.tapestry5.internal.plastic.asm.Handle; import org.apache.tapestry5.internal.plastic.asm.Label; import org.apache.tapestry5.internal.plastic.asm.MethodVisitor; +import org.apache.tapestry5.internal.plastic.asm.ModuleVisitor; import org.apache.tapestry5.internal.plastic.asm.Opcodes; import org.apache.tapestry5.internal.plastic.asm.Type; import org.apache.tapestry5.internal.plastic.asm.TypePath; @@ -52,8 +53,8 @@ import org.xml.sax.helpers.DefaultHandler; * document into Java class file. This class can be feeded by any kind of SAX * 2.0 event producers, e.g. XML parser, XSLT or XPath engines, or custom code. * - * @see org.apache.tapestry5.internal.plastic.asm.xml.SAXClassAdapter - * @see org.apache.tapestry5.internal.plastic.asm.xml.Processor + * @see org.objectweb.asm.xml.SAXClassAdapter + * @see org.objectweb.asm.xml.Processor * * @author Eugene Kuleshov */ @@ -90,6 +91,18 @@ public class ASMContentHandler extends DefaultHandler implements Opcodes { RULES.add(BASE + "/outerclass", new OuterClassRule()); RULES.add(BASE + "/innerclass", new InnerClassRule()); RULES.add(BASE + "/source", new SourceRule()); + + ModuleRule moduleRule = new ModuleRule(); + RULES.add(BASE + "/module", moduleRule); + RULES.add(BASE + "/module/main-class", moduleRule); + RULES.add(BASE + "/module/target", moduleRule); + RULES.add(BASE + "/module/packages", moduleRule); + RULES.add(BASE + "/module/requires", moduleRule); + RULES.add(BASE + "/module/exports", moduleRule); + RULES.add(BASE + "/module/exports/to", moduleRule); + RULES.add(BASE + "/module/uses", moduleRule); + RULES.add(BASE + "/module/provides", moduleRule); + RULES.add(BASE + "/field", new FieldRule()); RULES.add(BASE + "/method", new MethodRule()); @@ -362,7 +375,7 @@ public class ASMContentHandler extends DefaultHandler implements Opcodes { String name = lName == null || lName.length() == 0 ? qName : lName; // Compute the current matching rule - StringBuffer sb = new StringBuffer(match); + StringBuilder sb = new StringBuilder(match); if (match.length() > 0) { sb.append('/'); } @@ -554,13 +567,16 @@ public class ASMContentHandler extends DefaultHandler implements Opcodes { int dotIndex = val.indexOf('.'); int descIndex = val.indexOf('(', dotIndex + 1); int tagIndex = val.lastIndexOf('('); - - int tag = Integer.parseInt(val.substring(tagIndex + 1, - val.length() - 1)); + int itfIndex = val.indexOf(' ', tagIndex + 1); + + boolean itf = itfIndex != -1; + int tag = Integer.parseInt( + val.substring(tagIndex + 1, + itf? val.length() - 1: itfIndex)); String owner = val.substring(0, dotIndex); String name = val.substring(dotIndex + 1, descIndex); String desc = val.substring(descIndex, tagIndex - 1); - return new Handle(tag, owner, name, desc); + return new Handle(tag, owner, name, desc, itf); } catch (RuntimeException e) { throw new SAXException("Malformed handle " + val, e); @@ -568,7 +584,7 @@ public class ASMContentHandler extends DefaultHandler implements Opcodes { } private final String decode(final String val) throws SAXException { - StringBuffer sb = new StringBuffer(val.length()); + StringBuilder sb = new StringBuilder(val.length()); try { int n = 0; while (n < val.length()) { @@ -672,6 +688,15 @@ public class ASMContentHandler extends DefaultHandler implements Opcodes { if (s.indexOf("mandated") != -1) { access |= ACC_MANDATED; } + if (s.indexOf("module") != -1) { + access |= ACC_MODULE; + } + if (s.indexOf("open") != -1) { + access |= ACC_OPEN; + } + if (s.indexOf("transitive") != -1) { + access |= ACC_TRANSITIVE; + } return access; } } @@ -740,7 +765,91 @@ public class ASMContentHandler extends DefaultHandler implements Opcodes { push(cv); } } + + /** + * ModuleRule: module, requires, exports, opens, uses and provides + */ + final class ModuleRule extends Rule { + @Override + public final void begin(final String element, final Attributes attrs) + throws SAXException { + if ("module".equals(element)) { + push(cv.visitModule(attrs.getValue("name"), + getAccess(attrs.getValue("access")), + attrs.getValue("version"))); + } else if ("main-class".equals(element)) { + ModuleVisitor mv = (ModuleVisitor) peek(); + mv.visitMainClass(attrs.getValue("name")); + } else if ("packages".equals(element)) { + ModuleVisitor mv = (ModuleVisitor) peek(); + mv.visitPackage(attrs.getValue("name")); + } else if ("requires".equals(element)) { + ModuleVisitor mv = (ModuleVisitor) peek(); + int access = getAccess(attrs.getValue("access")); + if ((access & Opcodes.ACC_STATIC) != 0) { + access = access & ~Opcodes.ACC_STATIC | Opcodes.ACC_STATIC_PHASE; + } + mv.visitRequire(attrs.getValue("module"), + access, attrs.getValue("version")); + } else if ("exports".equals(element)) { + push(attrs.getValue("name")); + push(getAccess(attrs.getValue("access"))); + ArrayList<String> list = new ArrayList<String>(); + push(list); + } else if ("opens".equals(element)) { + push(attrs.getValue("name")); + push(getAccess(attrs.getValue("access"))); + ArrayList<String> list = new ArrayList<String>(); + push(list); + } else if ("to".equals(element)) { + @SuppressWarnings("unchecked") + ArrayList<String> list = (ArrayList<String>) peek(); + list.add(attrs.getValue("module")); + } else if ("uses".equals(element)) { + ModuleVisitor mv = (ModuleVisitor) peek(); + mv.visitUse(attrs.getValue("service")); + } else if ("provides".equals(element)) { + push(attrs.getValue("service")); + push(0); // see end() below + ArrayList<String> list = new ArrayList<String>(); + push(list); + } else if ("with".equals(element)) { + @SuppressWarnings("unchecked") + ArrayList<String> list = (ArrayList<String>) peek(); + list.add(attrs.getValue("provider")); + } + } + @Override + public void end(final String element) { + boolean exports = "exports".equals(element); + boolean opens = "opens".equals(element); + boolean provides = "provides".equals(element); + if (exports | opens | provides) { + @SuppressWarnings("unchecked") + ArrayList<String> list = (ArrayList<String>) pop(); + int access = (Integer) pop(); + String name = (String) pop(); + String[] tos = null; + if (!list.isEmpty()) { + tos = list.toArray(new String[list.size()]); + } + ModuleVisitor mv = (ModuleVisitor) peek(); + if (exports) { + mv.visitExport(name, access, tos); + } else { + if (opens) { + mv.visitOpen(name, access, tos); + } else { + mv.visitProvide(name, tos); + } + } + } else if ("module".equals(element)) { + ((ModuleVisitor) pop()).visitEnd(); + } + } + } + /** * OuterClassRule */ http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/74324b31/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/Processor.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/Processor.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/Processor.java index eb26b11..a04930f 100644 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/Processor.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/xml/Processor.java @@ -29,29 +29,47 @@ */ package org.apache.tapestry5.internal.plastic.asm.xml; -import org.apache.tapestry5.internal.plastic.asm.ClassReader; -import org.apache.tapestry5.internal.plastic.asm.ClassWriter; -import org.xml.sax.*; -import org.xml.sax.ext.LexicalHandler; -import org.xml.sax.helpers.AttributesImpl; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.XMLReaderFactory; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; -import javax.xml.transform.*; +import javax.xml.transform.Source; +import javax.xml.transform.Templates; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamSource; -import java.io.*; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; + +import org.apache.tapestry5.internal.plastic.asm.ClassReader; +import org.apache.tapestry5.internal.plastic.asm.ClassWriter; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.ext.LexicalHandler; +import org.xml.sax.helpers.AttributesImpl; +import org.xml.sax.helpers.DefaultHandler; +import org.xml.sax.helpers.XMLReaderFactory; /** * Processor is a command line tool that can be used for bytecode waving * directed by XSL transformation. - * + * <p> * In order to use a concrete XSLT engine, system property * <tt>javax.xml.transform.TransformerFactory</tt> must be set to one of the * following values. @@ -694,7 +712,7 @@ public class Processor { private final void writeAttributes(final Attributes atts) throws IOException { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int len = atts.getLength(); for (int i = 0; i < len; i++) { sb.append(' ').append(atts.getLocalName(i)).append("=\"") @@ -711,7 +729,7 @@ public class Processor { * @return encoded string */ private static final String esc(final String str) { - StringBuffer sb = new StringBuffer(str.length()); + StringBuilder sb = new StringBuilder(str.length()); for (int i = 0; i < str.length(); i++) { char ch = str.charAt(i); switch (ch) { @@ -773,7 +791,7 @@ public class Processor { * {@link java.net.ContentHandlerFactory ContentHandlerFactory}. This is * useful for running XSLT engine against large XML document that will * hardly fit into the memory all together. - * + * <p> * TODO use complete path for subdocumentRoot */ private static final class InputSlicingHandler extends DefaultHandler { @@ -877,7 +895,7 @@ public class Processor { * useful for running XSLT engine against large XML document that will * hardly fit into the memory all together. * - * + * <p> * TODO use complete path for subdocumentRoot */ private static final class OutputSlicingHandler extends DefaultHandler {
