http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/AnnotationNode.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/AnnotationNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/AnnotationNode.java old mode 100644 new mode 100755 index c25ab8c..3cc051f --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/AnnotationNode.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/AnnotationNode.java @@ -1,291 +1,230 @@ -/*** - * 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. - */ +// 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.tree; import java.util.ArrayList; import java.util.List; - import org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor; import org.apache.tapestry5.internal.plastic.asm.Opcodes; /** * A node that represents an annotation. - * + * * @author Eric Bruneton */ public class AnnotationNode extends AnnotationVisitor { - /** - * The class descriptor of the annotation class. - */ - public String desc; - - /** - * The name value pairs of this annotation. Each name value pair is stored - * as two consecutive elements in the list. The name is a {@link String}, - * and the value may be a {@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 a - * two elements String array (for enumeration values), an - * {@link AnnotationNode}, or a {@link List} of values of one of the - * preceding types. The list may be <tt>null</tt> if there is no name value - * pair. - */ - public List<Object> values; - - /** - * Constructs a new {@link AnnotationNode}. <i>Subclasses must not use this - * constructor</i>. Instead, they must use the - * {@link #AnnotationNode(int, String)} version. - * - * @param desc - * the class descriptor of the annotation class. - * @throws IllegalStateException - * If a subclass calls this constructor. - */ - public AnnotationNode(final String desc) { - this(Opcodes.ASM6, desc); - if (getClass() != AnnotationNode.class) { - throw new IllegalStateException(); - } + /** The class descriptor of the annotation class. */ + public String desc; + + /** + * The name value pairs of this annotation. Each name value pair is stored as two consecutive + * elements in the list. The name is a {@link String}, and the value may be a {@link Byte}, {@link + * Boolean}, {@link Character}, {@link Short}, {@link Integer}, {@link Long}, {@link Float}, + * {@link Double}, {@link String} or {@link org.apache.tapestry5.internal.plastic.asm.Type}, or a two elements String + * array (for enumeration values), an {@link AnnotationNode}, or a {@link List} of values of one + * of the preceding types. The list may be {@literal null} if there is no name value pair. + */ + public List<Object> values; + + /** + * Constructs a new {@link AnnotationNode}. <i>Subclasses must not use this constructor</i>. + * Instead, they must use the {@link #AnnotationNode(int, String)} version. + * + * @param descriptor the class descriptor of the annotation class. + * @throws IllegalStateException If a subclass calls this constructor. + */ + public AnnotationNode(final String descriptor) { + this(Opcodes.ASM7, descriptor); + if (getClass() != AnnotationNode.class) { + throw new IllegalStateException(); } - - /** - * Constructs a new {@link AnnotationNode}. - * - * @param api - * the ASM API version implemented by this visitor. Must be one - * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. - * @param desc - * the class descriptor of the annotation class. - */ - public AnnotationNode(final int api, final String desc) { - super(api); - this.desc = desc; + } + + /** + * Constructs a new {@link AnnotationNode}. + * + * @param api the ASM API version implemented by this visitor. Must be one of {@link + * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. + * @param descriptor the class descriptor of the annotation class. + */ + public AnnotationNode(final int api, final String descriptor) { + super(api); + this.desc = descriptor; + } + + /** + * Constructs a new {@link AnnotationNode} to visit an array value. + * + * @param values where the visited values must be stored. + */ + AnnotationNode(final List<Object> values) { + super(Opcodes.ASM7); + this.values = values; + } + + // ------------------------------------------------------------------------ + // Implementation of the AnnotationVisitor abstract class + // ------------------------------------------------------------------------ + + @Override + public void visit(final String name, final Object value) { + if (values == null) { + values = new ArrayList<Object>(this.desc != null ? 2 : 1); } - - /** - * Constructs a new {@link AnnotationNode} to visit an array value. - * - * @param values - * where the visited values must be stored. - */ - AnnotationNode(final List<Object> values) { - super(Opcodes.ASM6); - this.values = values; + if (this.desc != null) { + values.add(name); } - - // ------------------------------------------------------------------------ - // Implementation of the AnnotationVisitor abstract class - // ------------------------------------------------------------------------ - - @Override - public void visit(final String name, final Object value) { - if (values == null) { - values = new ArrayList<Object>(this.desc != null ? 2 : 1); - } - if (this.desc != null) { - values.add(name); - } - if (value instanceof byte[]) { - byte[] v = (byte[]) value; - ArrayList<Byte> l = new ArrayList<Byte>(v.length); - for (byte b : v) { - l.add(b); - } - values.add(l); - } else if (value instanceof boolean[]) { - boolean[] v = (boolean[]) value; - ArrayList<Boolean> l = new ArrayList<Boolean>(v.length); - for (boolean b : v) { - l.add(b); - } - values.add(l); - } else if (value instanceof short[]) { - short[] v = (short[]) value; - ArrayList<Short> l = new ArrayList<Short>(v.length); - for (short s : v) { - l.add(s); - } - values.add(l); - } else if (value instanceof char[]) { - char[] v = (char[]) value; - ArrayList<Character> l = new ArrayList<Character>(v.length); - for (char c : v) { - l.add(c); - } - values.add(l); - } else if (value instanceof int[]) { - int[] v = (int[]) value; - ArrayList<Integer> l = new ArrayList<Integer>(v.length); - for (int i : v) { - l.add(i); - } - values.add(l); - } else if (value instanceof long[]) { - long[] v = (long[]) value; - ArrayList<Long> l = new ArrayList<Long>(v.length); - for (long lng : v) { - l.add(lng); - } - values.add(l); - } else if (value instanceof float[]) { - float[] v = (float[]) value; - ArrayList<Float> l = new ArrayList<Float>(v.length); - for (float f : v) { - l.add(f); - } - values.add(l); - } else if (value instanceof double[]) { - double[] v = (double[]) value; - ArrayList<Double> l = new ArrayList<Double>(v.length); - for (double d : v) { - l.add(d); - } - values.add(l); - } else { - values.add(value); - } + if (value instanceof byte[]) { + values.add(Util.asArrayList((byte[]) value)); + } else if (value instanceof boolean[]) { + values.add(Util.asArrayList((boolean[]) value)); + } else if (value instanceof short[]) { + values.add(Util.asArrayList((short[]) value)); + } else if (value instanceof char[]) { + values.add(Util.asArrayList((char[]) value)); + } else if (value instanceof int[]) { + values.add(Util.asArrayList((int[]) value)); + } else if (value instanceof long[]) { + values.add(Util.asArrayList((long[]) value)); + } else if (value instanceof float[]) { + values.add(Util.asArrayList((float[]) value)); + } else if (value instanceof double[]) { + values.add(Util.asArrayList((double[]) value)); + } else { + values.add(value); } + } - @Override - public void visitEnum(final String name, final String desc, - final String value) { - if (values == null) { - values = new ArrayList<Object>(this.desc != null ? 2 : 1); - } - if (this.desc != null) { - values.add(name); - } - values.add(new String[] { desc, value }); + @Override + public void visitEnum(final String name, final String descriptor, final String value) { + if (values == null) { + values = new ArrayList<Object>(this.desc != null ? 2 : 1); } - - @Override - public AnnotationVisitor visitAnnotation(final String name, - final String desc) { - if (values == null) { - values = new ArrayList<Object>(this.desc != null ? 2 : 1); - } - if (this.desc != null) { - values.add(name); - } - AnnotationNode annotation = new AnnotationNode(desc); - values.add(annotation); - return annotation; + if (this.desc != null) { + values.add(name); } + values.add(new String[] {descriptor, value}); + } - @Override - public AnnotationVisitor visitArray(final String name) { - if (values == null) { - values = new ArrayList<Object>(this.desc != null ? 2 : 1); - } - if (this.desc != null) { - values.add(name); - } - List<Object> array = new ArrayList<Object>(); - values.add(array); - return new AnnotationNode(array); + @Override + public AnnotationVisitor visitAnnotation(final String name, final String descriptor) { + if (values == null) { + values = new ArrayList<Object>(this.desc != null ? 2 : 1); } - - @Override - public void visitEnd() { + if (this.desc != null) { + values.add(name); } - - // ------------------------------------------------------------------------ - // Accept methods - // ------------------------------------------------------------------------ - - /** - * Checks that this annotation node is compatible with the given ASM API - * version. This methods checks that this node, and all its nodes - * recursively, do not contain elements that were introduced in more recent - * versions of the ASM API than the given version. - * - * @param api - * an ASM API version. Must be one of {@link Opcodes#ASM4}, - * {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. - */ - public void check(final int api) { - // nothing to do + AnnotationNode annotation = new AnnotationNode(descriptor); + values.add(annotation); + return annotation; + } + + @Override + public AnnotationVisitor visitArray(final String name) { + if (values == null) { + values = new ArrayList<Object>(this.desc != null ? 2 : 1); } - - /** - * Makes the given visitor visit this annotation. - * - * @param av - * an annotation visitor. Maybe <tt>null</tt>. - */ - public void accept(final AnnotationVisitor av) { - if (av != null) { - if (values != null) { - for (int i = 0; i < values.size(); i += 2) { - String name = (String) values.get(i); - Object value = values.get(i + 1); - accept(av, name, value); - } - } - av.visitEnd(); + if (this.desc != null) { + values.add(name); + } + List<Object> array = new ArrayList<Object>(); + values.add(array); + return new AnnotationNode(array); + } + + @Override + public void visitEnd() { + // Nothing to do. + } + + // ------------------------------------------------------------------------ + // Accept methods + // ------------------------------------------------------------------------ + + /** + * Checks that this annotation node is compatible with the given ASM API version. This method + * checks that this node, and all its children recursively, do not contain elements that were + * introduced in more recent versions of the ASM API than the given version. + * + * @param api an ASM API version. Must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5}, + * {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. + */ + public void check(final int api) { + // nothing to do + } + + /** + * Makes the given visitor visit this annotation. + * + * @param annotationVisitor an annotation visitor. Maybe {@literal null}. + */ + public void accept(final AnnotationVisitor annotationVisitor) { + if (annotationVisitor != null) { + if (values != null) { + for (int i = 0, n = values.size(); i < n; i += 2) { + String name = (String) values.get(i); + Object value = values.get(i + 1); + accept(annotationVisitor, name, value); } + } + annotationVisitor.visitEnd(); } - - /** - * Makes the given visitor visit a given annotation value. - * - * @param av - * an annotation visitor. Maybe <tt>null</tt>. - * @param name - * the value name. - * @param value - * the actual value. - */ - public static void accept(final AnnotationVisitor av, final String name, - final Object value) { - if (av != null) { - if (value instanceof String[]) { - String[] typeconst = (String[]) value; - av.visitEnum(name, typeconst[0], typeconst[1]); - } else if (value instanceof AnnotationNode) { - AnnotationNode an = (AnnotationNode) value; - an.accept(av.visitAnnotation(name, an.desc)); - } else if (value instanceof List) { - AnnotationVisitor v = av.visitArray(name); - if (v != null) { - List<?> array = (List<?>) value; - for (int j = 0; j < array.size(); ++j) { - accept(v, null, array.get(j)); - } - v.visitEnd(); - } - } else { - av.visit(name, value); - } + } + + /** + * Makes the given visitor visit a given annotation value. + * + * @param annotationVisitor an annotation visitor. Maybe {@literal null}. + * @param name the value name. + * @param value the actual value. + */ + public static void accept( + final AnnotationVisitor annotationVisitor, final String name, final Object value) { + if (annotationVisitor != null) { + if (value instanceof String[]) { + String[] typeValue = (String[]) value; + annotationVisitor.visitEnum(name, typeValue[0], typeValue[1]); + } else if (value instanceof AnnotationNode) { + AnnotationNode annotationValue = (AnnotationNode) value; + annotationValue.accept(annotationVisitor.visitAnnotation(name, annotationValue.desc)); + } else if (value instanceof List) { + AnnotationVisitor arrayAnnotationVisitor = annotationVisitor.visitArray(name); + if (arrayAnnotationVisitor != null) { + List<?> arrayValue = (List<?>) value; + for (int i = 0, n = arrayValue.size(); i < n; ++i) { + accept(arrayAnnotationVisitor, null, arrayValue.get(i)); + } + arrayAnnotationVisitor.visitEnd(); } + } else { + annotationVisitor.visit(name, value); + } } + } }
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/ClassNode.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/ClassNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/ClassNode.java old mode 100644 new mode 100755 index 386161c..83cf5d4 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/ClassNode.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/ClassNode.java @@ -1,38 +1,34 @@ -/*** - * 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. - */ +// 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.tree; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; - import org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor; import org.apache.tapestry5.internal.plastic.asm.Attribute; import org.apache.tapestry5.internal.plastic.asm.ClassVisitor; @@ -44,414 +40,391 @@ import org.apache.tapestry5.internal.plastic.asm.TypePath; /** * A node that represents a class. - * + * * @author Eric Bruneton */ public class ClassNode extends ClassVisitor { - /** - * The class version. - */ - public int version; - - /** - * The class's access flags (see {@link org.objectweb.asm.Opcodes}). This - * field also indicates if the class is deprecated. - */ - public int access; - - /** - * The internal name of the class (see - * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). - */ - public String name; - - /** - * The signature of the class. May be <tt>null</tt>. - */ - public String signature; - - /** - * 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. - */ - public String superName; - - /** - * The internal names of the class's interfaces (see - * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). This - * list is a list of {@link String} objects. - */ - public List<String> interfaces; - - /** - * The name of the source file from which this class was compiled. May be - * <tt>null</tt>. - */ - public String sourceFile; - - /** - * Debug information to compute the correspondence between source and - * compiled elements of the class. May be <tt>null</tt>. - */ - public String sourceDebug; - - /** - * Module information. May be <tt>null</tt>. - */ - public ModuleNode module; - - /** - * The internal name of the enclosing class of the class. May be - * <tt>null</tt>. - */ - public String outerClass; - - /** - * The name of the method that contains the class, or <tt>null</tt> if the - * class is not enclosed in a method. - */ - public String outerMethod; - - /** - * The descriptor of the method that contains the class, or <tt>null</tt> if - * the class is not enclosed in a method. - */ - public String outerMethodDesc; - - /** - * The runtime visible annotations of this class. This list is a list of - * {@link AnnotationNode} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.tree.AnnotationNode - * @label visible - */ - public List<AnnotationNode> visibleAnnotations; - - /** - * The runtime invisible annotations of this class. This list is a list of - * {@link AnnotationNode} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.tree.AnnotationNode - * @label invisible - */ - public List<AnnotationNode> invisibleAnnotations; - - /** - * The runtime visible type annotations of this class. This list is a list - * of {@link TypeAnnotationNode} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.tree.TypeAnnotationNode - * @label visible - */ - public List<TypeAnnotationNode> visibleTypeAnnotations; - - /** - * The runtime invisible type annotations of this class. This list is a list - * of {@link TypeAnnotationNode} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.tree.TypeAnnotationNode - * @label invisible - */ - public List<TypeAnnotationNode> invisibleTypeAnnotations; - - /** - * The non standard attributes of this class. This list is a list of - * {@link Attribute} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.Attribute - */ - public List<Attribute> attrs; - - /** - * Informations about the inner classes of this class. This list is a list - * of {@link InnerClassNode} objects. - * - * @associates org.objectweb.asm.tree.InnerClassNode - */ - public List<InnerClassNode> innerClasses; - - /** - * The fields of this class. This list is a list of {@link FieldNode} - * objects. - * - * @associates org.objectweb.asm.tree.FieldNode - */ - public List<FieldNode> fields; - - /** - * The methods of this class. This list is a list of {@link MethodNode} - * objects. - * - * @associates org.objectweb.asm.tree.MethodNode - */ - public List<MethodNode> methods; - - /** - * Constructs a new {@link ClassNode}. <i>Subclasses must not use this - * constructor</i>. Instead, they must use the {@link #ClassNode(int)} - * version. - * - * @throws IllegalStateException - * If a subclass calls this constructor. - */ - public ClassNode() { - this(Opcodes.ASM6); - if (getClass() != ClassNode.class) { - throw new IllegalStateException(); - } + /** + * The class version. The minor version is stored in the 16 most significant bits, and the major + * version in the 16 least significant bits. + */ + public int version; + + /** + * The class's access flags (see {@link org.apache.tapestry5.internal.plastic.asm.Opcodes}). This field also indicates if + * the class is deprecated. + */ + public int access; + + /** The internal name of this class (see {@link org.apache.tapestry5.internal.plastic.asm.Type#getInternalName}). */ + public String name; + + /** The signature of this class. May be {@literal null}. */ + public String signature; + + /** + * The internal of name of the super class (see {@link org.apache.tapestry5.internal.plastic.asm.Type#getInternalName}). + * For interfaces, the super class is {@link Object}. May be {@literal null}, but only for the + * {@link Object} class. + */ + public String superName; + + /** + * The internal names of the interfaces directly implemented by this class (see {@link + * org.apache.tapestry5.internal.plastic.asm.Type#getInternalName}). + */ + public List<String> interfaces; + + /** The name of the source file from which this class was compiled. May be {@literal null}. */ + public String sourceFile; + + /** + * The correspondence between source and compiled elements of this class. May be {@literal null}. + */ + public String sourceDebug; + + /** The module stored in this class. May be {@literal null}. */ + public ModuleNode module; + + /** The internal name of the enclosing class of this class. May be {@literal null}. */ + public String outerClass; + + /** + * The name of the method that contains this class, or {@literal null} if this class is not + * enclosed in a method. + */ + public String outerMethod; + + /** + * The descriptor of the method that contains this class, or {@literal null} if this class is not + * enclosed in a method. + */ + public String outerMethodDesc; + + /** The runtime visible annotations of this class. May be {@literal null}. */ + public List<AnnotationNode> visibleAnnotations; + + /** The runtime invisible annotations of this class. May be {@literal null}. */ + public List<AnnotationNode> invisibleAnnotations; + + /** The runtime visible type annotations of this class. May be {@literal null}. */ + public List<TypeAnnotationNode> visibleTypeAnnotations; + + /** The runtime invisible type annotations of this class. May be {@literal null}. */ + public List<TypeAnnotationNode> invisibleTypeAnnotations; + + /** The non standard attributes of this class. May be {@literal null}. */ + public List<Attribute> attrs; + + /** The inner classes of this class. */ + public List<InnerClassNode> innerClasses; + + /** The internal name of the nest host class of this class. May be {@literal null}. */ + public String nestHostClass; + + /** The internal names of the nest members of this class. May be {@literal null}. */ + public List<String> nestMembers; + + /** The fields of this class. */ + public List<FieldNode> fields; + + /** The methods of this class. */ + public List<MethodNode> methods; + + /** + * Constructs a new {@link ClassNode}. <i>Subclasses must not use this constructor</i>. Instead, + * they must use the {@link #ClassNode(int)} version. + * + * @throws IllegalStateException If a subclass calls this constructor. + */ + public ClassNode() { + this(Opcodes.ASM7); + if (getClass() != ClassNode.class) { + throw new IllegalStateException(); } - - /** - * Constructs a new {@link ClassNode}. - * - * @param api - * the ASM API version implemented by this visitor. Must be one - * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. - */ - public ClassNode(final int api) { - super(api); - this.interfaces = new ArrayList<String>(); - this.innerClasses = new ArrayList<InnerClassNode>(); - this.fields = new ArrayList<FieldNode>(); - this.methods = new ArrayList<MethodNode>(); + } + + /** + * Constructs a new {@link ClassNode}. + * + * @param api the ASM API version implemented by this visitor. Must be one of {@link + * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. + */ + public ClassNode(final int api) { + super(api); + this.interfaces = new ArrayList<String>(); + this.innerClasses = new ArrayList<InnerClassNode>(); + this.fields = new ArrayList<FieldNode>(); + this.methods = new ArrayList<MethodNode>(); + } + + // ----------------------------------------------------------------------------------------------- + // Implementation of the ClassVisitor abstract class + // ----------------------------------------------------------------------------------------------- + + @Override + public void visit( + final int version, + final int access, + final String name, + final String signature, + final String superName, + final String[] interfaces) { + this.version = version; + this.access = access; + this.name = name; + this.signature = signature; + this.superName = superName; + this.interfaces = Util.asArrayList(interfaces); + } + + @Override + public void visitSource(final String file, final String debug) { + sourceFile = file; + sourceDebug = debug; + } + + @Override + public ModuleVisitor visitModule(final String name, final int access, final String version) { + module = new ModuleNode(name, access, version); + return module; + } + + @Override + public void visitNestHost(final String nestHost) { + this.nestHostClass = nestHost; + } + + @Override + public void visitOuterClass(final String owner, final String name, final String descriptor) { + outerClass = owner; + outerMethod = name; + outerMethodDesc = descriptor; + } + + @Override + public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) { + AnnotationNode annotation = new AnnotationNode(descriptor); + if (visible) { + if (visibleAnnotations == null) { + visibleAnnotations = new ArrayList<AnnotationNode>(1); + } + visibleAnnotations.add(annotation); + } else { + if (invisibleAnnotations == null) { + invisibleAnnotations = new ArrayList<AnnotationNode>(1); + } + invisibleAnnotations.add(annotation); + } + return annotation; + } + + @Override + public AnnotationVisitor visitTypeAnnotation( + final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { + TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor); + if (visible) { + if (visibleTypeAnnotations == null) { + visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); + } + visibleTypeAnnotations.add(typeAnnotation); + } else { + if (invisibleTypeAnnotations == null) { + invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); + } + invisibleTypeAnnotations.add(typeAnnotation); } + return typeAnnotation; + } - // ------------------------------------------------------------------------ - // Implementation of the ClassVisitor abstract class - // ------------------------------------------------------------------------ - - @Override - public void visit(final int version, final int access, final String name, - final String signature, final String superName, - final String[] interfaces) { - this.version = version; - this.access = access; - this.name = name; - this.signature = signature; - this.superName = superName; - if (interfaces != null) { - this.interfaces.addAll(Arrays.asList(interfaces)); - } + @Override + public void visitAttribute(final Attribute attribute) { + if (attrs == null) { + attrs = new ArrayList<Attribute>(1); } + attrs.add(attribute); + } - @Override - public void visitSource(final String file, final String debug) { - sourceFile = file; - sourceDebug = debug; + @Override + public void visitNestMember(final String nestMember) { + if (nestMembers == null) { + nestMembers = new ArrayList<String>(); } - - @Override - public ModuleVisitor visitModule(final String name, final int access, - final String version) { - return module = new ModuleNode(name, access, version); + nestMembers.add(nestMember); + } + + @Override + public void visitInnerClass( + final String name, final String outerName, final String innerName, final int access) { + InnerClassNode innerClass = new InnerClassNode(name, outerName, innerName, access); + innerClasses.add(innerClass); + } + + @Override + public FieldVisitor visitField( + final int access, + final String name, + final String descriptor, + final String signature, + final Object value) { + FieldNode field = new FieldNode(access, name, descriptor, signature, value); + fields.add(field); + return field; + } + + @Override + public MethodVisitor visitMethod( + final int access, + final String name, + final String descriptor, + final String signature, + final String[] exceptions) { + MethodNode method = new MethodNode(access, name, descriptor, signature, exceptions); + methods.add(method); + return method; + } + + @Override + public void visitEnd() { + // Nothing to do. + } + + // ----------------------------------------------------------------------------------------------- + // Accept method + // ----------------------------------------------------------------------------------------------- + + /** + * Checks that this class node is compatible with the given ASM API version. This method checks + * that this node, and all its children recursively, do not contain elements that were introduced + * in more recent versions of the ASM API than the given version. + * + * @param api an ASM API version. Must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5}, + * {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. + */ + public void check(final int api) { + if (api < Opcodes.ASM7 && (nestHostClass != null || nestMembers != null)) { + throw new UnsupportedClassVersionException(); } - - @Override - public void visitOuterClass(final String owner, final String name, - final String desc) { - outerClass = owner; - outerMethod = name; - outerMethodDesc = desc; + if (api < Opcodes.ASM6 && module != null) { + throw new UnsupportedClassVersionException(); } - - @Override - public AnnotationVisitor visitAnnotation(final String desc, - final boolean visible) { - AnnotationNode an = new AnnotationNode(desc); - if (visible) { - if (visibleAnnotations == null) { - visibleAnnotations = new ArrayList<AnnotationNode>(1); - } - visibleAnnotations.add(an); - } else { - if (invisibleAnnotations == null) { - invisibleAnnotations = new ArrayList<AnnotationNode>(1); - } - invisibleAnnotations.add(an); - } - return an; + if (api < Opcodes.ASM5) { + if (visibleTypeAnnotations != null && !visibleTypeAnnotations.isEmpty()) { + throw new UnsupportedClassVersionException(); + } + if (invisibleTypeAnnotations != null && !invisibleTypeAnnotations.isEmpty()) { + throw new UnsupportedClassVersionException(); + } } - - @Override - public AnnotationVisitor visitTypeAnnotation(int typeRef, - TypePath typePath, String desc, boolean visible) { - TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc); - if (visible) { - if (visibleTypeAnnotations == null) { - visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); - } - visibleTypeAnnotations.add(an); - } else { - if (invisibleTypeAnnotations == null) { - invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); - } - invisibleTypeAnnotations.add(an); - } - return an; + // Check the annotations. + if (visibleAnnotations != null) { + for (int i = visibleAnnotations.size() - 1; i >= 0; --i) { + visibleAnnotations.get(i).check(api); + } } - - @Override - public void visitAttribute(final Attribute attr) { - if (attrs == null) { - attrs = new ArrayList<Attribute>(1); - } - attrs.add(attr); + if (invisibleAnnotations != null) { + for (int i = invisibleAnnotations.size() - 1; i >= 0; --i) { + invisibleAnnotations.get(i).check(api); + } } - - @Override - public void visitInnerClass(final String name, final String outerName, - final String innerName, final int access) { - InnerClassNode icn = new InnerClassNode(name, outerName, innerName, - access); - innerClasses.add(icn); + if (visibleTypeAnnotations != null) { + for (int i = visibleTypeAnnotations.size() - 1; i >= 0; --i) { + visibleTypeAnnotations.get(i).check(api); + } } - - @Override - public FieldVisitor visitField(final int access, final String name, - final String desc, final String signature, final Object value) { - FieldNode fn = new FieldNode(access, name, desc, signature, value); - fields.add(fn); - return fn; + if (invisibleTypeAnnotations != null) { + for (int i = invisibleTypeAnnotations.size() - 1; i >= 0; --i) { + invisibleTypeAnnotations.get(i).check(api); + } } - - @Override - public MethodVisitor visitMethod(final int access, final String name, - final String desc, final String signature, final String[] exceptions) { - MethodNode mn = new MethodNode(access, name, desc, signature, - exceptions); - methods.add(mn); - return mn; + for (int i = fields.size() - 1; i >= 0; --i) { + fields.get(i).check(api); } - - @Override - public void visitEnd() { + for (int i = methods.size() - 1; i >= 0; --i) { + methods.get(i).check(api); } - - // ------------------------------------------------------------------------ - // Accept method - // ------------------------------------------------------------------------ - - /** - * Checks that this class node is compatible with the given ASM API version. - * This methods checks that this node, and all its nodes recursively, do not - * contain elements that were introduced in more recent versions of the ASM - * API than the given version. - * - * @param api - * an ASM API version. Must be one of {@link Opcodes#ASM4}, - * {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. - */ - public void check(final int api) { - if (api < Opcodes.ASM6) { - if (module != null) { - throw new RuntimeException(); - } - } - if (api < Opcodes.ASM5) { - if (visibleTypeAnnotations != null - && visibleTypeAnnotations.size() > 0) { - throw new RuntimeException(); - } - if (invisibleTypeAnnotations != null - && invisibleTypeAnnotations.size() > 0) { - throw new RuntimeException(); - } - } - // checks attributes - int i, n; - n = visibleAnnotations == null ? 0 : visibleAnnotations.size(); - for (i = 0; i < n; ++i) { - visibleAnnotations.get(i).check(api); - } - n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size(); - for (i = 0; i < n; ++i) { - invisibleAnnotations.get(i).check(api); - } - n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size(); - for (i = 0; i < n; ++i) { - visibleTypeAnnotations.get(i).check(api); - } - n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations - .size(); - for (i = 0; i < n; ++i) { - invisibleTypeAnnotations.get(i).check(api); - } - for (FieldNode f : fields) { - f.check(api); - } - for (MethodNode m : methods) { - m.check(api); - } + } + + /** + * Makes the given class visitor visit this class. + * + * @param classVisitor a class visitor. + */ + public void accept(final ClassVisitor classVisitor) { + // Visit the header. + String[] interfacesArray = new String[this.interfaces.size()]; + this.interfaces.toArray(interfacesArray); + classVisitor.visit(version, access, name, signature, superName, interfacesArray); + // Visit the source. + if (sourceFile != null || sourceDebug != null) { + classVisitor.visitSource(sourceFile, sourceDebug); } - - /** - * Makes the given class visitor visit this class. - * - * @param cv - * a class visitor. - */ - public void accept(final ClassVisitor cv) { - // visits header - String[] interfaces = new String[this.interfaces.size()]; - this.interfaces.toArray(interfaces); - cv.visit(version, access, name, signature, superName, interfaces); - // visits source - if (sourceFile != null || sourceDebug != null) { - cv.visitSource(sourceFile, sourceDebug); - } - // visits module - if (module != null) { - module.accept(cv); - } - // visits outer class - if (outerClass != null) { - cv.visitOuterClass(outerClass, outerMethod, outerMethodDesc); - } - // visits attributes - int i, n; - n = visibleAnnotations == null ? 0 : visibleAnnotations.size(); - for (i = 0; i < n; ++i) { - AnnotationNode an = visibleAnnotations.get(i); - an.accept(cv.visitAnnotation(an.desc, true)); - } - n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size(); - for (i = 0; i < n; ++i) { - AnnotationNode an = invisibleAnnotations.get(i); - an.accept(cv.visitAnnotation(an.desc, false)); - } - n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size(); - for (i = 0; i < n; ++i) { - TypeAnnotationNode an = visibleTypeAnnotations.get(i); - an.accept(cv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, - true)); - } - n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations - .size(); - for (i = 0; i < n; ++i) { - TypeAnnotationNode an = invisibleTypeAnnotations.get(i); - an.accept(cv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, - false)); - } - n = attrs == null ? 0 : attrs.size(); - for (i = 0; i < n; ++i) { - cv.visitAttribute(attrs.get(i)); - } - // visits inner classes - for (i = 0; i < innerClasses.size(); ++i) { - innerClasses.get(i).accept(cv); - } - // visits fields - for (i = 0; i < fields.size(); ++i) { - fields.get(i).accept(cv); - } - // visits methods - for (i = 0; i < methods.size(); ++i) { - methods.get(i).accept(cv); - } - // visits end - cv.visitEnd(); + // Visit the module. + if (module != null) { + module.accept(classVisitor); + } + // Visit the nest host class. + if (nestHostClass != null) { + classVisitor.visitNestHost(nestHostClass); + } + // Visit the outer class. + if (outerClass != null) { + classVisitor.visitOuterClass(outerClass, outerMethod, outerMethodDesc); + } + // Visit the annotations. + if (visibleAnnotations != null) { + for (int i = 0, n = visibleAnnotations.size(); i < n; ++i) { + AnnotationNode annotation = visibleAnnotations.get(i); + annotation.accept(classVisitor.visitAnnotation(annotation.desc, true)); + } + } + if (invisibleAnnotations != null) { + for (int i = 0, n = invisibleAnnotations.size(); i < n; ++i) { + AnnotationNode annotation = invisibleAnnotations.get(i); + annotation.accept(classVisitor.visitAnnotation(annotation.desc, false)); + } + } + if (visibleTypeAnnotations != null) { + for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) { + TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i); + typeAnnotation.accept( + classVisitor.visitTypeAnnotation( + typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true)); + } + } + if (invisibleTypeAnnotations != null) { + for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) { + TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i); + typeAnnotation.accept( + classVisitor.visitTypeAnnotation( + typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false)); + } + } + // Visit the non standard attributes. + if (attrs != null) { + for (int i = 0, n = attrs.size(); i < n; ++i) { + classVisitor.visitAttribute(attrs.get(i)); + } + } + // Visit the nest members. + if (nestMembers != null) { + for (int i = 0, n = nestMembers.size(); i < n; ++i) { + classVisitor.visitNestMember(nestMembers.get(i)); + } + } + // Visit the inner classes. + for (int i = 0, n = innerClasses.size(); i < n; ++i) { + innerClasses.get(i).accept(classVisitor); + } + // Visit the fields. + for (int i = 0, n = fields.size(); i < n; ++i) { + fields.get(i).accept(classVisitor); + } + // Visit the methods. + for (int i = 0, n = methods.size(); i < n; ++i) { + methods.get(i).accept(classVisitor); } + classVisitor.visitEnd(); + } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldInsnNode.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldInsnNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldInsnNode.java old mode 100644 new mode 100755 index 075519e..97bf7b0 --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldInsnNode.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldInsnNode.java @@ -1,110 +1,96 @@ -/*** - * 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. - */ +// 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.tree; import java.util.Map; - import org.apache.tapestry5.internal.plastic.asm.MethodVisitor; /** - * A node that represents a field instruction. A field instruction is an - * instruction that loads or stores the value of a field of an object. - * + * A node that represents a field instruction. A field instruction is an instruction that loads or + * stores the value of a field of an object. + * * @author Eric Bruneton */ public class FieldInsnNode extends AbstractInsnNode { - /** - * The internal name of the field's owner class (see - * {@link org.objectweb.asm.Type#getInternalName() getInternalName}). - */ - public String owner; + /** + * The internal name of the field's owner class (see {@link + * org.apache.tapestry5.internal.plastic.asm.Type#getInternalName}). + */ + public String owner; - /** - * The field's name. - */ - public String name; + /** The field's name. */ + public String name; - /** - * The field's descriptor (see {@link org.objectweb.asm.Type}). - */ - public String desc; + /** The field's descriptor (see {@link org.apache.tapestry5.internal.plastic.asm.Type}). */ + public String desc; - /** - * Constructs a new {@link FieldInsnNode}. - * - * @param opcode - * the opcode of the type instruction to be constructed. This - * opcode must be 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}). - */ - public FieldInsnNode(final int opcode, final String owner, - final String name, final String desc) { - super(opcode); - this.owner = owner; - this.name = name; - this.desc = desc; - } + /** + * Constructs a new {@link FieldInsnNode}. + * + * @param opcode the opcode of the type instruction to be constructed. This opcode must be + * GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD. + * @param owner the internal name of the field's owner class (see {@link + * org.apache.tapestry5.internal.plastic.asm.Type#getInternalName}). + * @param name the field's name. + * @param descriptor the field's descriptor (see {@link org.apache.tapestry5.internal.plastic.asm.Type}). + */ + public FieldInsnNode( + final int opcode, final String owner, final String name, final String descriptor) { + super(opcode); + this.owner = owner; + this.name = name; + this.desc = descriptor; + } - /** - * Sets the opcode of this instruction. - * - * @param opcode - * the new instruction opcode. This opcode must be GETSTATIC, - * PUTSTATIC, GETFIELD or PUTFIELD. - */ - public void setOpcode(final int opcode) { - this.opcode = opcode; - } + /** + * Sets the opcode of this instruction. + * + * @param opcode the new instruction opcode. This opcode must be GETSTATIC, PUTSTATIC, GETFIELD or + * PUTFIELD. + */ + public void setOpcode(final int opcode) { + this.opcode = opcode; + } - @Override - public int getType() { - return FIELD_INSN; - } + @Override + public int getType() { + return FIELD_INSN; + } - @Override - public void accept(final MethodVisitor mv) { - mv.visitFieldInsn(opcode, owner, name, desc); - acceptAnnotations(mv); - } + @Override + public void accept(final MethodVisitor methodVisitor) { + methodVisitor.visitFieldInsn(opcode, owner, name, desc); + acceptAnnotations(methodVisitor); + } - @Override - public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) { - return new FieldInsnNode(opcode, owner, name, desc) - .cloneAnnotations(this); - } + @Override + public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) { + return new FieldInsnNode(opcode, owner, name, desc).cloneAnnotations(this); + } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldNode.java ---------------------------------------------------------------------- diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldNode.java old mode 100644 new mode 100755 index b4e08d8..c1b516c --- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldNode.java +++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/FieldNode.java @@ -1,37 +1,34 @@ -/*** - * 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. - */ +// 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.tree; import java.util.ArrayList; import java.util.List; - import org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor; import org.apache.tapestry5.internal.plastic.asm.Attribute; import org.apache.tapestry5.internal.plastic.asm.ClassVisitor; @@ -41,267 +38,223 @@ import org.apache.tapestry5.internal.plastic.asm.TypePath; /** * A node that represents a field. - * + * * @author Eric Bruneton */ public class FieldNode extends FieldVisitor { - /** - * The field's access flags (see {@link org.objectweb.asm.Opcodes}). This - * field also indicates if the field is synthetic and/or deprecated. - */ - public int access; + /** + * The field's access flags (see {@link org.apache.tapestry5.internal.plastic.asm.Opcodes}). This field also indicates if + * the field is synthetic and/or deprecated. + */ + public int access; - /** - * The field's name. - */ - public String name; + /** The field's name. */ + public String name; - /** - * The field's descriptor (see {@link org.objectweb.asm.Type}). - */ - public String desc; + /** The field's descriptor (see {@link org.apache.tapestry5.internal.plastic.asm.Type}). */ + public String desc; - /** - * The field's signature. May be <tt>null</tt>. - */ - public String signature; + /** The field's signature. May be {@literal null}. */ + public String signature; - /** - * The field's initial value. This field, 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}. - */ - public Object value; + /** + * The field's initial value. This field, which may be {@literal null} 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}. + */ + public Object value; - /** - * The runtime visible annotations of this field. This list is a list of - * {@link AnnotationNode} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.tree.AnnotationNode - * @label visible - */ - public List<AnnotationNode> visibleAnnotations; + /** The runtime visible annotations of this field. May be {@literal null}. */ + public List<AnnotationNode> visibleAnnotations; - /** - * The runtime invisible annotations of this field. This list is a list of - * {@link AnnotationNode} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.tree.AnnotationNode - * @label invisible - */ - public List<AnnotationNode> invisibleAnnotations; + /** The runtime invisible annotations of this field. May be {@literal null}. */ + public List<AnnotationNode> invisibleAnnotations; - /** - * The runtime visible type annotations of this field. This list is a list - * of {@link TypeAnnotationNode} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.tree.TypeAnnotationNode - * @label visible - */ - public List<TypeAnnotationNode> visibleTypeAnnotations; + /** The runtime visible type annotations of this field. May be {@literal null}. */ + public List<TypeAnnotationNode> visibleTypeAnnotations; - /** - * The runtime invisible type annotations of this field. This list is a list - * of {@link TypeAnnotationNode} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.tree.TypeAnnotationNode - * @label invisible - */ - public List<TypeAnnotationNode> invisibleTypeAnnotations; + /** The runtime invisible type annotations of this field. May be {@literal null}. */ + public List<TypeAnnotationNode> invisibleTypeAnnotations; - /** - * The non standard attributes of this field. This list is a list of - * {@link Attribute} objects. May be <tt>null</tt>. - * - * @associates org.objectweb.asm.Attribute - */ - public List<Attribute> attrs; + /** The non standard attributes of this field. * May be {@literal null}. */ + public List<Attribute> attrs; - /** - * Constructs a new {@link FieldNode}. <i>Subclasses must not use this - * constructor</i>. Instead, they must use the - * {@link #FieldNode(int, int, String, String, String, Object)} version. - * - * @param access - * the field's access flags (see - * {@link org.objectweb.asm.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. - * @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}. - * @throws IllegalStateException - * If a subclass calls this constructor. - */ - public FieldNode(final int access, final String name, final String desc, - final String signature, final Object value) { - this(Opcodes.ASM6, access, name, desc, signature, value); - if (getClass() != FieldNode.class) { - throw new IllegalStateException(); - } + /** + * Constructs a new {@link FieldNode}. <i>Subclasses must not use this constructor</i>. Instead, + * they must use the {@link #FieldNode(int, int, String, String, String, Object)} version. + * + * @param access the field's access flags (see {@link org.apache.tapestry5.internal.plastic.asm.Opcodes}). This parameter + * also indicates if the field is synthetic and/or deprecated. + * @param name the field's name. + * @param descriptor the field's descriptor (see {@link org.apache.tapestry5.internal.plastic.asm.Type}). + * @param signature the field's signature. + * @param value the field's initial value. This parameter, which may be {@literal null} 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}. + * @throws IllegalStateException If a subclass calls this constructor. + */ + public FieldNode( + final int access, + final String name, + final String descriptor, + final String signature, + final Object value) { + this(Opcodes.ASM7, access, name, descriptor, signature, value); + if (getClass() != FieldNode.class) { + throw new IllegalStateException(); } + } - /** - * Constructs a new {@link FieldNode}. <i>Subclasses must not use this - * constructor</i>. - * - * @param api - * the ASM API version implemented by this visitor. Must be one - * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}. - * @param access - * the field's access flags (see - * {@link org.objectweb.asm.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. - * @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}. - */ - public FieldNode(final int api, final int access, final String name, - final String desc, final String signature, final Object value) { - super(api); - this.access = access; - this.name = name; - this.desc = desc; - this.signature = signature; - this.value = value; - } + /** + * Constructs a new {@link FieldNode}. <i>Subclasses must not use this constructor</i>. + * + * @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM4} + * or {@link Opcodes#ASM5}. + * @param access the field's access flags (see {@link org.apache.tapestry5.internal.plastic.asm.Opcodes}). This parameter + * also indicates if the field is synthetic and/or deprecated. + * @param name the field's name. + * @param descriptor the field's descriptor (see {@link org.apache.tapestry5.internal.plastic.asm.Type}). + * @param signature the field's signature. + * @param value the field's initial value. This parameter, which may be {@literal null} 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}. + */ + public FieldNode( + final int api, + final int access, + final String name, + final String descriptor, + final String signature, + final Object value) { + super(api); + this.access = access; + this.name = name; + this.desc = descriptor; + this.signature = signature; + this.value = value; + } - // ------------------------------------------------------------------------ - // Implementation of the FieldVisitor abstract class - // ------------------------------------------------------------------------ + // ----------------------------------------------------------------------------------------------- + // Implementation of the FieldVisitor abstract class + // ----------------------------------------------------------------------------------------------- - @Override - public AnnotationVisitor visitAnnotation(final String desc, - final boolean visible) { - AnnotationNode an = new AnnotationNode(desc); - if (visible) { - if (visibleAnnotations == null) { - visibleAnnotations = new ArrayList<AnnotationNode>(1); - } - visibleAnnotations.add(an); - } else { - if (invisibleAnnotations == null) { - invisibleAnnotations = new ArrayList<AnnotationNode>(1); - } - invisibleAnnotations.add(an); - } - return an; + @Override + public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) { + AnnotationNode annotation = new AnnotationNode(descriptor); + if (visible) { + if (visibleAnnotations == null) { + visibleAnnotations = new ArrayList<AnnotationNode>(1); + } + visibleAnnotations.add(annotation); + } else { + if (invisibleAnnotations == null) { + invisibleAnnotations = new ArrayList<AnnotationNode>(1); + } + invisibleAnnotations.add(annotation); } + return annotation; + } - @Override - public AnnotationVisitor visitTypeAnnotation(int typeRef, - TypePath typePath, String desc, boolean visible) { - TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc); - if (visible) { - if (visibleTypeAnnotations == null) { - visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); - } - visibleTypeAnnotations.add(an); - } else { - if (invisibleTypeAnnotations == null) { - invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); - } - invisibleTypeAnnotations.add(an); - } - return an; + @Override + public AnnotationVisitor visitTypeAnnotation( + final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { + TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor); + if (visible) { + if (visibleTypeAnnotations == null) { + visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); + } + visibleTypeAnnotations.add(typeAnnotation); + } else { + if (invisibleTypeAnnotations == null) { + invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1); + } + invisibleTypeAnnotations.add(typeAnnotation); } + return typeAnnotation; + } - @Override - public void visitAttribute(final Attribute attr) { - if (attrs == null) { - attrs = new ArrayList<Attribute>(1); - } - attrs.add(attr); + @Override + public void visitAttribute(final Attribute attribute) { + if (attrs == null) { + attrs = new ArrayList<Attribute>(1); } + attrs.add(attribute); + } - @Override - public void visitEnd() { - } + @Override + public void visitEnd() { + // Nothing to do. + } - // ------------------------------------------------------------------------ - // Accept methods - // ------------------------------------------------------------------------ + // ----------------------------------------------------------------------------------------------- + // Accept methods + // ----------------------------------------------------------------------------------------------- - /** - * Checks that this field node is compatible with the given ASM API version. - * This methods checks that this node, and all its nodes recursively, do not - * contain elements that were introduced in more recent versions of the ASM - * API than the given version. - * - * @param api - * an ASM API version. Must be one of {@link Opcodes#ASM4}, - * {@link Opcodes#ASM5} or {@link Opcodes#ASM6}. - */ - public void check(final int api) { - if (api == Opcodes.ASM4) { - if (visibleTypeAnnotations != null - && visibleTypeAnnotations.size() > 0) { - throw new RuntimeException(); - } - if (invisibleTypeAnnotations != null - && invisibleTypeAnnotations.size() > 0) { - throw new RuntimeException(); - } - } + /** + * Checks that this field node is compatible with the given ASM API version. This method checks + * that this node, and all its children recursively, do not contain elements that were introduced + * in more recent versions of the ASM API than the given version. + * + * @param api an ASM API version. Must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5}, + * {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. + */ + public void check(final int api) { + if (api == Opcodes.ASM4) { + if (visibleTypeAnnotations != null && !visibleTypeAnnotations.isEmpty()) { + throw new UnsupportedClassVersionException(); + } + if (invisibleTypeAnnotations != null && !invisibleTypeAnnotations.isEmpty()) { + throw new UnsupportedClassVersionException(); + } } + } - /** - * Makes the given class visitor visit this field. - * - * @param cv - * a class visitor. - */ - public void accept(final ClassVisitor cv) { - FieldVisitor fv = cv.visitField(access, name, desc, signature, value); - if (fv == null) { - return; - } - int i, n; - n = visibleAnnotations == null ? 0 : visibleAnnotations.size(); - for (i = 0; i < n; ++i) { - AnnotationNode an = visibleAnnotations.get(i); - an.accept(fv.visitAnnotation(an.desc, true)); - } - n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size(); - for (i = 0; i < n; ++i) { - AnnotationNode an = invisibleAnnotations.get(i); - an.accept(fv.visitAnnotation(an.desc, false)); - } - n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size(); - for (i = 0; i < n; ++i) { - TypeAnnotationNode an = visibleTypeAnnotations.get(i); - an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, - true)); - } - n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations - .size(); - for (i = 0; i < n; ++i) { - TypeAnnotationNode an = invisibleTypeAnnotations.get(i); - an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, - false)); - } - n = attrs == null ? 0 : attrs.size(); - for (i = 0; i < n; ++i) { - fv.visitAttribute(attrs.get(i)); - } - fv.visitEnd(); + /** + * Makes the given class visitor visit this field. + * + * @param classVisitor a class visitor. + */ + public void accept(final ClassVisitor classVisitor) { + FieldVisitor fieldVisitor = classVisitor.visitField(access, name, desc, signature, value); + if (fieldVisitor == null) { + return; + } + // Visit the annotations. + if (visibleAnnotations != null) { + for (int i = 0, n = visibleAnnotations.size(); i < n; ++i) { + AnnotationNode annotation = visibleAnnotations.get(i); + annotation.accept(fieldVisitor.visitAnnotation(annotation.desc, true)); + } + } + if (invisibleAnnotations != null) { + for (int i = 0, n = invisibleAnnotations.size(); i < n; ++i) { + AnnotationNode annotation = invisibleAnnotations.get(i); + annotation.accept(fieldVisitor.visitAnnotation(annotation.desc, false)); + } + } + if (visibleTypeAnnotations != null) { + for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) { + TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i); + typeAnnotation.accept( + fieldVisitor.visitTypeAnnotation( + typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true)); + } + } + if (invisibleTypeAnnotations != null) { + for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) { + TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i); + typeAnnotation.accept( + fieldVisitor.visitTypeAnnotation( + typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false)); + } + } + // Visit the non standard attributes. + if (attrs != null) { + for (int i = 0, n = attrs.size(); i < n; ++i) { + fieldVisitor.visitAttribute(attrs.get(i)); + } } + fieldVisitor.visitEnd(); + } }
