You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by ka...@apache.org on 2014/03/25 19:30:05 UTC

[17/23] FIXED - TAP5-2214: Make tapestry5 java8 compatible - update ASM source to 5.0.1, should be jdk 1.5 compatible, see ASM bug "317132 ASM 5.0 do not supported JDK 1.5?"

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0ac605d/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Opcodes.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Opcodes.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Opcodes.java
index ac7c671..d899c5e 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Opcodes.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Opcodes.java
@@ -37,7 +37,7 @@ package org.apache.tapestry5.internal.plastic.asm;
  * opcodes are therefore not defined in this interface. Likewise for LDC,
  * automatically replaced by LDC_W or LDC2_W when necessary, WIDE, GOTO_W and
  * JSR_W.
- *
+ * 
  * @author Eric Bruneton
  * @author Eugene Kuleshov
  */
@@ -46,6 +46,7 @@ public interface Opcodes {
     // ASM API versions
 
     int ASM4 = 4 << 16 | 0 << 8 | 0;
+    int ASM5 = 5 << 16 | 0 << 8 | 0;
 
     // versions
 
@@ -56,6 +57,7 @@ public interface Opcodes {
     int V1_5 = 0 << 16 | 49;
     int V1_6 = 0 << 16 | 50;
     int V1_7 = 0 << 16 | 51;
+    int V1_8 = 0 << 16 | 52;
 
     // access flags
 
@@ -63,7 +65,7 @@ public interface Opcodes {
     int ACC_PRIVATE = 0x0002; // class, field, method
     int ACC_PROTECTED = 0x0004; // class, field, method
     int ACC_STATIC = 0x0008; // field, method
-    int ACC_FINAL = 0x0010; // class, field, method
+    int ACC_FINAL = 0x0010; // class, field, method, parameter
     int ACC_SUPER = 0x0020; // class
     int ACC_SYNCHRONIZED = 0x0020; // method
     int ACC_VOLATILE = 0x0040; // field
@@ -74,9 +76,10 @@ public interface Opcodes {
     int ACC_INTERFACE = 0x0200; // class
     int ACC_ABSTRACT = 0x0400; // class, method
     int ACC_STRICT = 0x0800; // method
-    int ACC_SYNTHETIC = 0x1000; // class, field, method
+    int ACC_SYNTHETIC = 0x1000; // class, field, method, parameter
     int ACC_ANNOTATION = 0x2000; // class
     int ACC_ENUM = 0x4000; // class(?) field inner
+    int ACC_MANDATED = 0x8000; // parameter
 
     // ASM specific pseudo access flags
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0ac605d/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Type.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Type.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Type.java
index 6011aa4..0b526a0 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Type.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Type.java
@@ -35,7 +35,7 @@ import java.lang.reflect.Method;
 /**
  * A Java field or method type. This class can be used to make it easier to
  * manipulate type and method descriptors.
- *
+ * 
  * @author Eric Bruneton
  * @author Chris Nokleberg
  */
@@ -189,14 +189,17 @@ public class Type {
 
     /**
      * Constructs a reference type.
-     *
-     * @param sort the sort of the reference type to be constructed.
-     * @param buf a buffer containing the descriptor of the previous type.
-     * @param off the offset of this descriptor in the previous buffer.
-     * @param len the length of this descriptor.
-     */
-    private Type(final int sort, final char[] buf, final int off, final int len)
-    {
+     * 
+     * @param sort
+     *            the sort of the reference type to be constructed.
+     * @param buf
+     *            a buffer containing the descriptor of the previous type.
+     * @param off
+     *            the offset of this descriptor in the previous buffer.
+     * @param len
+     *            the length of this descriptor.
+     */
+    private Type(final int sort, final char[] buf, final int off, final int len) {
         this.sort = sort;
         this.buf = buf;
         this.off = off;
@@ -205,8 +208,9 @@ public class Type {
 
     /**
      * Returns the Java type corresponding to the given type descriptor.
-     *
-     * @param typeDescriptor a field or method type descriptor.
+     * 
+     * @param typeDescriptor
+     *            a field or method type descriptor.
      * @return the Java type corresponding to the given type descriptor.
      */
     public static Type getType(final String typeDescriptor) {
@@ -215,8 +219,9 @@ public class Type {
 
     /**
      * Returns the Java type corresponding to the given internal name.
-     *
-     * @param internalName an internal name.
+     * 
+     * @param internalName
+     *            an internal name.
      * @return the Java type corresponding to the given internal name.
      */
     public static Type getObjectType(final String internalName) {
@@ -227,8 +232,9 @@ public class Type {
     /**
      * Returns the Java type corresponding to the given method descriptor.
      * Equivalent to <code>Type.getType(methodDescriptor)</code>.
-     *
-     * @param methodDescriptor a method descriptor.
+     * 
+     * @param methodDescriptor
+     *            a method descriptor.
      * @return the Java type corresponding to the given method descriptor.
      */
     public static Type getMethodType(final String methodDescriptor) {
@@ -238,19 +244,24 @@ public class Type {
     /**
      * Returns the Java method type corresponding to the given argument and
      * return types.
-     *
-     * @param returnType the return type of the method.
-     * @param argumentTypes the argument types of the method.
-     * @return the Java type corresponding to the given argument and return types.
+     * 
+     * @param returnType
+     *            the return type of the method.
+     * @param argumentTypes
+     *            the argument types of the method.
+     * @return the Java type corresponding to the given argument and return
+     *         types.
      */
-    public static Type getMethodType(final Type returnType, final Type... argumentTypes) {
+    public static Type getMethodType(final Type returnType,
+            final Type... argumentTypes) {
         return getType(getMethodDescriptor(returnType, argumentTypes));
     }
 
     /**
      * Returns the Java type corresponding to the given class.
-     *
-     * @param c a class.
+     * 
+     * @param c
+     *            a class.
      * @return the Java type corresponding to the given class.
      */
     public static Type getType(final Class<?> c) {
@@ -281,8 +292,9 @@ public class Type {
 
     /**
      * Returns the Java method type corresponding to the given constructor.
-     *
-     * @param c a {@link Constructor Constructor} object.
+     * 
+     * @param c
+     *            a {@link Constructor Constructor} object.
      * @return the Java method type corresponding to the given constructor.
      */
     public static Type getType(final Constructor<?> c) {
@@ -291,8 +303,9 @@ public class Type {
 
     /**
      * Returns the Java method type corresponding to the given method.
-     *
-     * @param m a {@link Method Method} object.
+     * 
+     * @param m
+     *            a {@link Method Method} object.
      * @return the Java method type corresponding to the given method.
      */
     public static Type getType(final Method m) {
@@ -302,8 +315,9 @@ public class Type {
     /**
      * Returns the Java types corresponding to the argument types of the given
      * method descriptor.
-     *
-     * @param methodDescriptor a method descriptor.
+     * 
+     * @param methodDescriptor
+     *            a method descriptor.
      * @return the Java types corresponding to the argument types of the given
      *         method descriptor.
      */
@@ -337,8 +351,9 @@ public class Type {
     /**
      * Returns the Java types corresponding to the argument types of the given
      * method.
-     *
-     * @param method a method.
+     * 
+     * @param method
+     *            a method.
      * @return the Java types corresponding to the argument types of the given
      *         method.
      */
@@ -354,8 +369,9 @@ public class Type {
     /**
      * Returns the Java type corresponding to the return type of the given
      * method descriptor.
-     *
-     * @param methodDescriptor a method descriptor.
+     * 
+     * @param methodDescriptor
+     *            a method descriptor.
      * @return the Java type corresponding to the return type of the given
      *         method descriptor.
      */
@@ -367,8 +383,9 @@ public class Type {
     /**
      * Returns the Java type corresponding to the return type of the given
      * method.
-     *
-     * @param method a method.
+     * 
+     * @param method
+     *            a method.
      * @return the Java type corresponding to the return type of the given
      *         method.
      */
@@ -378,13 +395,14 @@ public class Type {
 
     /**
      * Computes the size of the arguments and of the return value of a method.
-     *
-     * @param desc the descriptor of a method.
+     * 
+     * @param desc
+     *            the descriptor of a method.
      * @return the size of the arguments of the method (plus one for the
      *         implicit this argument), argSize, and the size of its return
      *         value, retSize, packed into a single int i =
-     *         <tt>(argSize << 2) | retSize</tt> (argSize is therefore equal
-     *         to <tt>i >> 2</tt>, and retSize to <tt>i & 0x03</tt>).
+     *         <tt>(argSize &lt;&lt; 2) | retSize</tt> (argSize is therefore equal to
+     *         <tt>i &gt;&gt; 2</tt>, and retSize to <tt>i &amp; 0x03</tt>).
      */
     public static int getArgumentsAndReturnSizes(final String desc) {
         int n = 1;
@@ -418,53 +436,55 @@ public class Type {
      * Returns the Java type corresponding to the given type descriptor. For
      * method descriptors, buf is supposed to contain nothing more than the
      * descriptor itself.
-     *
-     * @param buf a buffer containing a type descriptor.
-     * @param off the offset of this descriptor in the previous buffer.
+     * 
+     * @param buf
+     *            a buffer containing a type descriptor.
+     * @param off
+     *            the offset of this descriptor in the previous buffer.
      * @return the Java type corresponding to the given type descriptor.
      */
     private static Type getType(final char[] buf, final int off) {
         int len;
         switch (buf[off]) {
-            case 'V':
-                return VOID_TYPE;
-            case 'Z':
-                return BOOLEAN_TYPE;
-            case 'C':
-                return CHAR_TYPE;
-            case 'B':
-                return BYTE_TYPE;
-            case 'S':
-                return SHORT_TYPE;
-            case 'I':
-                return INT_TYPE;
-            case 'F':
-                return FLOAT_TYPE;
-            case 'J':
-                return LONG_TYPE;
-            case 'D':
-                return DOUBLE_TYPE;
-            case '[':
-                len = 1;
-                while (buf[off + len] == '[') {
-                    ++len;
-                }
-                if (buf[off + len] == 'L') {
-                    ++len;
-                    while (buf[off + len] != ';') {
-                        ++len;
-                    }
-                }
-                return new Type(ARRAY, buf, off, len + 1);
-            case 'L':
-                len = 1;
+        case 'V':
+            return VOID_TYPE;
+        case 'Z':
+            return BOOLEAN_TYPE;
+        case 'C':
+            return CHAR_TYPE;
+        case 'B':
+            return BYTE_TYPE;
+        case 'S':
+            return SHORT_TYPE;
+        case 'I':
+            return INT_TYPE;
+        case 'F':
+            return FLOAT_TYPE;
+        case 'J':
+            return LONG_TYPE;
+        case 'D':
+            return DOUBLE_TYPE;
+        case '[':
+            len = 1;
+            while (buf[off + len] == '[') {
+                ++len;
+            }
+            if (buf[off + len] == 'L') {
+                ++len;
                 while (buf[off + len] != ';') {
                     ++len;
                 }
-                return new Type(OBJECT, buf, off + 1, len - 1);
+            }
+            return new Type(ARRAY, buf, off, len + 1);
+        case 'L':
+            len = 1;
+            while (buf[off + len] != ';') {
+                ++len;
+            }
+            return new Type(OBJECT, buf, off + 1, len - 1);
             // case '(':
-            default:
-                return new Type(METHOD, buf, 0, buf.length);
+        default:
+            return new Type(METHOD, buf, off, buf.length - off);
         }
     }
 
@@ -474,12 +494,12 @@ public class Type {
 
     /**
      * Returns the sort of this Java type.
-     *
-     * @return {@link #VOID VOID}, {@link #BOOLEAN BOOLEAN},
-     *         {@link #CHAR CHAR}, {@link #BYTE BYTE}, {@link #SHORT SHORT},
-     *         {@link #INT INT}, {@link #FLOAT FLOAT}, {@link #LONG LONG},
-     *         {@link #DOUBLE DOUBLE}, {@link #ARRAY ARRAY},
-     *         {@link #OBJECT OBJECT} or {@link #METHOD METHOD}.
+     * 
+     * @return {@link #VOID VOID}, {@link #BOOLEAN BOOLEAN}, {@link #CHAR CHAR},
+     *         {@link #BYTE BYTE}, {@link #SHORT SHORT}, {@link #INT INT},
+     *         {@link #FLOAT FLOAT}, {@link #LONG LONG}, {@link #DOUBLE DOUBLE},
+     *         {@link #ARRAY ARRAY}, {@link #OBJECT OBJECT} or {@link #METHOD
+     *         METHOD}.
      */
     public int getSort() {
         return sort;
@@ -488,7 +508,7 @@ public class Type {
     /**
      * Returns the number of dimensions of this array type. This method should
      * only be used for an array type.
-     *
+     * 
      * @return the number of dimensions of this array type.
      */
     public int getDimensions() {
@@ -502,7 +522,7 @@ public class Type {
     /**
      * Returns the type of the elements of this array type. This method should
      * only be used for an array type.
-     *
+     * 
      * @return Returns the type of the elements of this array type.
      */
     public Type getElementType() {
@@ -512,39 +532,39 @@ public class Type {
     /**
      * Returns the binary name of the class corresponding to this type. This
      * method must not be used on method types.
-     *
+     * 
      * @return the binary name of the class corresponding to this type.
      */
     public String getClassName() {
         switch (sort) {
-            case VOID:
-                return "void";
-            case BOOLEAN:
-                return "boolean";
-            case CHAR:
-                return "char";
-            case BYTE:
-                return "byte";
-            case SHORT:
-                return "short";
-            case INT:
-                return "int";
-            case FLOAT:
-                return "float";
-            case LONG:
-                return "long";
-            case DOUBLE:
-                return "double";
-            case ARRAY:
-                StringBuffer b = new StringBuffer(getElementType().getClassName());
-                for (int i = getDimensions(); i > 0; --i) {
-                    b.append("[]");
-                }
-                return b.toString();
-            case OBJECT:
-                return new String(buf, off, len).replace('/', '.');
-            default:
-                return null;
+        case VOID:
+            return "void";
+        case BOOLEAN:
+            return "boolean";
+        case CHAR:
+            return "char";
+        case BYTE:
+            return "byte";
+        case SHORT:
+            return "short";
+        case INT:
+            return "int";
+        case FLOAT:
+            return "float";
+        case LONG:
+            return "long";
+        case DOUBLE:
+            return "double";
+        case ARRAY:
+            StringBuffer b = new StringBuffer(getElementType().getClassName());
+            for (int i = getDimensions(); i > 0; --i) {
+                b.append("[]");
+            }
+            return b.toString();
+        case OBJECT:
+            return new String(buf, off, len).replace('/', '.');
+        default:
+            return null;
         }
     }
 
@@ -553,7 +573,7 @@ public class Type {
      * array type. The internal name of a class is its fully qualified name (as
      * returned by Class.getName(), where '.' are replaced by '/'. This method
      * should only be used for an object or array type.
-     *
+     * 
      * @return the internal name of the class corresponding to this object type.
      */
     public String getInternalName() {
@@ -563,7 +583,7 @@ public class Type {
     /**
      * Returns the argument types of methods of this type. This method should
      * only be used for method types.
-     *
+     * 
      * @return the argument types of methods of this type.
      */
     public Type[] getArgumentTypes() {
@@ -573,7 +593,7 @@ public class Type {
     /**
      * Returns the return type of methods of this type. This method should only
      * be used for method types.
-     *
+     * 
      * @return the return type of methods of this type.
      */
     public Type getReturnType() {
@@ -583,12 +603,13 @@ public class Type {
     /**
      * Returns the size of the arguments and of the return value of methods of
      * this type. This method should only be used for method types.
-     *
+     * 
      * @return the size of the arguments (plus one for the implicit this
      *         argument), argSize, and the size of the return value, retSize,
-     *         packed into a single int i = <tt>(argSize << 2) | retSize</tt>
-     *         (argSize is therefore equal to <tt>i >> 2</tt>, and retSize to
-     *         <tt>i & 0x03</tt>).
+     *         packed into a single
+     *         int i = <tt>(argSize &lt;&lt; 2) | retSize</tt>
+     *         (argSize is therefore equal to <tt>i &gt;&gt; 2</tt>,
+     *         and retSize to <tt>i &amp; 0x03</tt>).
      */
     public int getArgumentsAndReturnSizes() {
         return getArgumentsAndReturnSizes(getDescriptor());
@@ -600,7 +621,7 @@ public class Type {
 
     /**
      * Returns the descriptor corresponding to this Java type.
-     *
+     * 
      * @return the descriptor corresponding to this Java type.
      */
     public String getDescriptor() {
@@ -612,16 +633,16 @@ public class Type {
     /**
      * Returns the descriptor corresponding to the given argument and return
      * types.
-     *
-     * @param returnType the return type of the method.
-     * @param argumentTypes the argument types of the method.
+     * 
+     * @param returnType
+     *            the return type of the method.
+     * @param argumentTypes
+     *            the argument types of the method.
      * @return the descriptor corresponding to the given argument and return
      *         types.
      */
-    public static String getMethodDescriptor(
-        final Type returnType,
-        final Type... argumentTypes)
-    {
+    public static String getMethodDescriptor(final Type returnType,
+            final Type... argumentTypes) {
         StringBuffer buf = new StringBuffer();
         buf.append('(');
         for (int i = 0; i < argumentTypes.length; ++i) {
@@ -635,12 +656,14 @@ public class Type {
     /**
      * Appends the descriptor corresponding to this Java type to the given
      * string buffer.
-     *
-     * @param buf the string buffer to which the descriptor must be appended.
+     * 
+     * @param buf
+     *            the string buffer to which the descriptor must be appended.
      */
     private void getDescriptor(final StringBuffer buf) {
         if (this.buf == null) {
-            // descriptor is in byte 3 of 'off' for primitive types (buf == null)
+            // descriptor is in byte 3 of 'off' for primitive types (buf ==
+            // null)
             buf.append((char) ((off & 0xFF000000) >>> 24));
         } else if (sort == OBJECT) {
             buf.append('L');
@@ -660,8 +683,9 @@ public class Type {
      * Returns the internal name of the given class. The internal name of a
      * class is its fully qualified name, as returned by Class.getName(), where
      * '.' are replaced by '/'.
-     *
-     * @param c an object or array class.
+     * 
+     * @param c
+     *            an object or array class.
      * @return the internal name of the given class.
      */
     public static String getInternalName(final Class<?> c) {
@@ -670,8 +694,9 @@ public class Type {
 
     /**
      * Returns the descriptor corresponding to the given Java type.
-     *
-     * @param c an object class, a primitive class or an array class.
+     * 
+     * @param c
+     *            an object class, a primitive class or an array class.
      * @return the descriptor corresponding to the given class.
      */
     public static String getDescriptor(final Class<?> c) {
@@ -682,8 +707,9 @@ public class Type {
 
     /**
      * Returns the descriptor corresponding to the given constructor.
-     *
-     * @param c a {@link Constructor Constructor} object.
+     * 
+     * @param c
+     *            a {@link Constructor Constructor} object.
      * @return the descriptor of the given constructor.
      */
     public static String getConstructorDescriptor(final Constructor<?> c) {
@@ -698,8 +724,9 @@ public class Type {
 
     /**
      * Returns the descriptor corresponding to the given method.
-     *
-     * @param m a {@link Method Method} object.
+     * 
+     * @param m
+     *            a {@link Method Method} object.
      * @return the descriptor of the given method.
      */
     public static String getMethodDescriptor(final Method m) {
@@ -716,9 +743,11 @@ public class Type {
 
     /**
      * Appends the descriptor of the given class to the given string buffer.
-     *
-     * @param buf the string buffer to which the descriptor must be appended.
-     * @param c the class whose descriptor must be computed.
+     * 
+     * @param buf
+     *            the string buffer to which the descriptor must be appended.
+     * @param c
+     *            the class whose descriptor must be computed.
      */
     private static void getDescriptor(final StringBuffer buf, final Class<?> c) {
         Class<?> d = c;
@@ -770,7 +799,7 @@ public class Type {
     /**
      * Returns the size of values of this type. This method must not be used for
      * method types.
-     *
+     * 
      * @return the size of values of this type, i.e., 2 for <tt>long</tt> and
      *         <tt>double</tt>, 0 for <tt>void</tt> and 1 otherwise.
      */
@@ -782,10 +811,11 @@ public class Type {
     /**
      * Returns a JVM instruction opcode adapted to this Java type. This method
      * must not be used for method types.
-     *
-     * @param opcode a JVM instruction opcode. This opcode must be one of ILOAD,
-     *        ISTORE, IALOAD, IASTORE, IADD, ISUB, IMUL, IDIV, IREM, INEG, ISHL,
-     *        ISHR, IUSHR, IAND, IOR, IXOR and IRETURN.
+     * 
+     * @param opcode
+     *            a JVM instruction opcode. This opcode must be one of ILOAD,
+     *            ISTORE, IALOAD, IASTORE, IADD, ISUB, IMUL, IDIV, IREM, INEG,
+     *            ISHL, ISHR, IUSHR, IAND, IOR, IXOR and IRETURN.
      * @return an opcode that is similar to the given opcode, but adapted to
      *         this Java type. For example, if this type is <tt>float</tt> and
      *         <tt>opcode</tt> is IRETURN, this method returns FRETURN.
@@ -808,8 +838,9 @@ public class Type {
 
     /**
      * Tests if the given object is equal to this type.
-     *
-     * @param o the object to be compared to this type.
+     * 
+     * @param o
+     *            the object to be compared to this type.
      * @return <tt>true</tt> if the given object is equal to this type.
      */
     @Override
@@ -839,7 +870,7 @@ public class Type {
 
     /**
      * Returns a hash code value for this type.
-     *
+     * 
      * @return a hash code value for this type.
      */
     @Override
@@ -855,7 +886,7 @@ public class Type {
 
     /**
      * Returns a string representation of this type.
-     *
+     * 
      * @return the descriptor of this type.
      */
     @Override

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0ac605d/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/TypePath.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/TypePath.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/TypePath.java
new file mode 100644
index 0000000..b772d59
--- /dev/null
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/TypePath.java
@@ -0,0 +1,193 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2013 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;
+
+/**
+ * The path to a type argument, wildcard bound, array element type, or static
+ * inner type within an enclosing type.
+ * 
+ * @author Eric Bruneton
+ */
+public class TypePath {
+
+    /**
+     * A type path step that steps into the element type of an array type. See
+     * {@link #getStep getStep}.
+     */
+    public final static int ARRAY_ELEMENT = 0;
+
+    /**
+     * A type path step that steps into the nested type of a class type. See
+     * {@link #getStep getStep}.
+     */
+    public final static int INNER_TYPE = 1;
+
+    /**
+     * A type path step that steps into the bound of a wildcard type. See
+     * {@link #getStep getStep}.
+     */
+    public final static int WILDCARD_BOUND = 2;
+
+    /**
+     * A type path step that steps into a type argument of a generic type. See
+     * {@link #getStep getStep}.
+     */
+    public final static int TYPE_ARGUMENT = 3;
+
+    /**
+     * The byte array where the path is stored, in Java class file format.
+     */
+    byte[] b;
+
+    /**
+     * The offset of the first byte of the type path in 'b'.
+     */
+    int offset;
+
+    /**
+     * Creates a new type path.
+     * 
+     * @param b
+     *            the byte array containing the type path in Java class file
+     *            format.
+     * @param offset
+     *            the offset of the first byte of the type path in 'b'.
+     */
+    TypePath(byte[] b, int offset) {
+        this.b = b;
+        this.offset = offset;
+    }
+
+    /**
+     * Returns the length of this path.
+     * 
+     * @return the length of this path.
+     */
+    public int getLength() {
+        return b[offset];
+    }
+
+    /**
+     * Returns the value of the given step of this path.
+     * 
+     * @param index
+     *            an index between 0 and {@link #getLength()}, exclusive.
+     * @return {@link #ARRAY_ELEMENT ARRAY_ELEMENT}, {@link #INNER_TYPE
+     *         INNER_TYPE}, {@link #WILDCARD_BOUND WILDCARD_BOUND}, or
+     *         {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
+     */
+    public int getStep(int index) {
+        return b[offset + 2 * index + 1];
+    }
+
+    /**
+     * Returns the index of the type argument that the given step is stepping
+     * into. This method should only be used for steps whose value is
+     * {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
+     * 
+     * @param index
+     *            an index between 0 and {@link #getLength()}, exclusive.
+     * @return the index of the type argument that the given step is stepping
+     *         into.
+     */
+    public int getStepArgument(int index) {
+        return b[offset + 2 * index + 2];
+    }
+
+    /**
+     * Converts a type path in string form, in the format used by
+     * {@link #toString()}, into a TypePath object.
+     * 
+     * @param typePath
+     *            a type path in string form, in the format used by
+     *            {@link #toString()}. May be null or empty.
+     * @return the corresponding TypePath object, or null if the path is empty.
+     */
+    public static TypePath fromString(final String typePath) {
+        if (typePath == null || typePath.length() == 0) {
+            return null;
+        }
+        int n = typePath.length();
+        ByteVector out = new ByteVector(n);
+        out.putByte(0);
+        for (int i = 0; i < n;) {
+            char c = typePath.charAt(i++);
+            if (c == '[') {
+                out.put11(ARRAY_ELEMENT, 0);
+            } else if (c == '.') {
+                out.put11(INNER_TYPE, 0);
+            } else if (c == '*') {
+                out.put11(WILDCARD_BOUND, 0);
+            } else if (c >= '0' && c <= '9') {
+                int typeArg = c - '0';
+                while (i < n && (c = typePath.charAt(i)) >= '0' && c <= '9') {
+                    typeArg = typeArg * 10 + c - '0';
+                    i += 1;
+                }
+                out.put11(TYPE_ARGUMENT, typeArg);
+            }
+        }
+        out.data[0] = (byte) (out.length / 2);
+        return new TypePath(out.data, 0);
+    }
+
+    /**
+     * Returns a string representation of this type path. {@link #ARRAY_ELEMENT
+     * ARRAY_ELEMENT} steps are represented with '[', {@link #INNER_TYPE
+     * INNER_TYPE} steps with '.', {@link #WILDCARD_BOUND WILDCARD_BOUND} steps
+     * with '*' and {@link #TYPE_ARGUMENT TYPE_ARGUMENT} steps with their type
+     * argument index in decimal form.
+     */
+    @Override
+    public String toString() {
+        int length = getLength();
+        StringBuilder result = new StringBuilder(length * 2);
+        for (int i = 0; i < length; ++i) {
+            switch (getStep(i)) {
+            case ARRAY_ELEMENT:
+                result.append('[');
+                break;
+            case INNER_TYPE:
+                result.append('.');
+                break;
+            case WILDCARD_BOUND:
+                result.append('*');
+                break;
+            case TYPE_ARGUMENT:
+                result.append(getStepArgument(i));
+                break;
+            default:
+                result.append('_');
+            }
+        }
+        return result.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0ac605d/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/TypeReference.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/TypeReference.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/TypeReference.java
new file mode 100644
index 0000000..d518864
--- /dev/null
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/TypeReference.java
@@ -0,0 +1,452 @@
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2013 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;
+
+/**
+ * A reference to a type appearing in a class, field or method declaration, or
+ * on an instruction. Such a reference designates the part of the class where
+ * the referenced type is appearing (e.g. an 'extends', 'implements' or 'throws'
+ * clause, a 'new' instruction, a 'catch' clause, a type cast, a local variable
+ * declaration, etc).
+ * 
+ * @author Eric Bruneton
+ */
+public class TypeReference {
+
+    /**
+     * The sort of type references that target a type parameter of a generic
+     * class. See {@link #getSort getSort}.
+     */
+    public final static int CLASS_TYPE_PARAMETER = 0x00;
+
+    /**
+     * The sort of type references that target a type parameter of a generic
+     * method. See {@link #getSort getSort}.
+     */
+    public final static int METHOD_TYPE_PARAMETER = 0x01;
+
+    /**
+     * The sort of type references that target the super class of a class or one
+     * of the interfaces it implements. See {@link #getSort getSort}.
+     */
+    public final static int CLASS_EXTENDS = 0x10;
+
+    /**
+     * The sort of type references that target a bound of a type parameter of a
+     * generic class. See {@link #getSort getSort}.
+     */
+    public final static int CLASS_TYPE_PARAMETER_BOUND = 0x11;
+
+    /**
+     * The sort of type references that target a bound of a type parameter of a
+     * generic method. See {@link #getSort getSort}.
+     */
+    public final static int METHOD_TYPE_PARAMETER_BOUND = 0x12;
+
+    /**
+     * The sort of type references that target the type of a field. See
+     * {@link #getSort getSort}.
+     */
+    public final static int FIELD = 0x13;
+
+    /**
+     * The sort of type references that target the return type of a method. See
+     * {@link #getSort getSort}.
+     */
+    public final static int METHOD_RETURN = 0x14;
+
+    /**
+     * The sort of type references that target the receiver type of a method.
+     * See {@link #getSort getSort}.
+     */
+    public final static int METHOD_RECEIVER = 0x15;
+
+    /**
+     * The sort of type references that target the type of a formal parameter of
+     * a method. See {@link #getSort getSort}.
+     */
+    public final static int METHOD_FORMAL_PARAMETER = 0x16;
+
+    /**
+     * The sort of type references that target the type of an exception declared
+     * in the throws clause of a method. See {@link #getSort getSort}.
+     */
+    public final static int THROWS = 0x17;
+
+    /**
+     * The sort of type references that target the type of a local variable in a
+     * method. See {@link #getSort getSort}.
+     */
+    public final static int LOCAL_VARIABLE = 0x40;
+
+    /**
+     * The sort of type references that target the type of a resource variable
+     * in a method. See {@link #getSort getSort}.
+     */
+    public final static int RESOURCE_VARIABLE = 0x41;
+
+    /**
+     * The sort of type references that target the type of the exception of a
+     * 'catch' clause in a method. See {@link #getSort getSort}.
+     */
+    public final static int EXCEPTION_PARAMETER = 0x42;
+
+    /**
+     * The sort of type references that target the type declared in an
+     * 'instanceof' instruction. See {@link #getSort getSort}.
+     */
+    public final static int INSTANCEOF = 0x43;
+
+    /**
+     * The sort of type references that target the type of the object created by
+     * a 'new' instruction. See {@link #getSort getSort}.
+     */
+    public final static int NEW = 0x44;
+
+    /**
+     * The sort of type references that target the receiver type of a
+     * constructor reference. See {@link #getSort getSort}.
+     */
+    public final static int CONSTRUCTOR_REFERENCE = 0x45;
+
+    /**
+     * The sort of type references that target the receiver type of a method
+     * reference. See {@link #getSort getSort}.
+     */
+    public final static int METHOD_REFERENCE = 0x46;
+
+    /**
+     * The sort of type references that target the type declared in an explicit
+     * or implicit cast instruction. See {@link #getSort getSort}.
+     */
+    public final static int CAST = 0x47;
+
+    /**
+     * The sort of type references that target a type parameter of a generic
+     * constructor in a constructor call. See {@link #getSort getSort}.
+     */
+    public final static int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48;
+
+    /**
+     * The sort of type references that target a type parameter of a generic
+     * method in a method call. See {@link #getSort getSort}.
+     */
+    public final static int METHOD_INVOCATION_TYPE_ARGUMENT = 0x49;
+
+    /**
+     * The sort of type references that target a type parameter of a generic
+     * constructor in a constructor reference. See {@link #getSort getSort}.
+     */
+    public final static int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A;
+
+    /**
+     * The sort of type references that target a type parameter of a generic
+     * method in a method reference. See {@link #getSort getSort}.
+     */
+    public final static int METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B;
+
+    /**
+     * The type reference value in Java class file format.
+     */
+    private int value;
+
+    /**
+     * Creates a new TypeReference.
+     * 
+     * @param typeRef
+     *            the int encoded value of the type reference, as received in a
+     *            visit method related to type annotations, like
+     *            visitTypeAnnotation.
+     */
+    public TypeReference(int typeRef) {
+        this.value = typeRef;
+    }
+
+    /**
+     * Returns a type reference of the given sort.
+     * 
+     * @param sort
+     *            {@link #FIELD FIELD}, {@link #METHOD_RETURN METHOD_RETURN},
+     *            {@link #METHOD_RECEIVER METHOD_RECEIVER},
+     *            {@link #LOCAL_VARIABLE LOCAL_VARIABLE},
+     *            {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE},
+     *            {@link #INSTANCEOF INSTANCEOF}, {@link #NEW NEW},
+     *            {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE}, or
+     *            {@link #METHOD_REFERENCE METHOD_REFERENCE}.
+     * @return a type reference of the given sort.
+     */
+    public static TypeReference newTypeReference(int sort) {
+        return new TypeReference(sort << 24);
+    }
+
+    /**
+     * Returns a reference to a type parameter of a generic class or method.
+     * 
+     * @param sort
+     *            {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or
+     *            {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER}.
+     * @param paramIndex
+     *            the type parameter index.
+     * @return a reference to the given generic class or method type parameter.
+     */
+    public static TypeReference newTypeParameterReference(int sort,
+            int paramIndex) {
+        return new TypeReference((sort << 24) | (paramIndex << 16));
+    }
+
+    /**
+     * Returns a reference to a type parameter bound of a generic class or
+     * method.
+     * 
+     * @param sort
+     *            {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or
+     *            {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER}.
+     * @param paramIndex
+     *            the type parameter index.
+     * @param boundIndex
+     *            the type bound index within the above type parameters.
+     * @return a reference to the given generic class or method type parameter
+     *         bound.
+     */
+    public static TypeReference newTypeParameterBoundReference(int sort,
+            int paramIndex, int boundIndex) {
+        return new TypeReference((sort << 24) | (paramIndex << 16)
+                | (boundIndex << 8));
+    }
+
+    /**
+     * Returns a reference to the super class or to an interface of the
+     * 'implements' clause of a class.
+     * 
+     * @param itfIndex
+     *            the index of an interface in the 'implements' clause of a
+     *            class, or -1 to reference the super class of the class.
+     * @return a reference to the given super type of a class.
+     */
+    public static TypeReference newSuperTypeReference(int itfIndex) {
+        itfIndex &= 0xFFFF;
+        return new TypeReference((CLASS_EXTENDS << 24) | (itfIndex << 8));
+    }
+
+    /**
+     * Returns a reference to the type of a formal parameter of a method.
+     * 
+     * @param paramIndex
+     *            the formal parameter index.
+     * 
+     * @return a reference to the type of the given method formal parameter.
+     */
+    public static TypeReference newFormalParameterReference(int paramIndex) {
+        return new TypeReference((METHOD_FORMAL_PARAMETER << 24)
+                | (paramIndex << 16));
+    }
+
+    /**
+     * Returns a reference to the type of an exception, in a 'throws' clause of
+     * a method.
+     * 
+     * @param exceptionIndex
+     *            the index of an exception in a 'throws' clause of a method.
+     * 
+     * @return a reference to the type of the given exception.
+     */
+    public static TypeReference newExceptionReference(int exceptionIndex) {
+        return new TypeReference((THROWS << 24) | (exceptionIndex << 8));
+    }
+
+    /**
+     * Returns a reference to the type of the exception declared in a 'catch'
+     * clause of a method.
+     * 
+     * @param tryCatchBlockIndex
+     *            the index of a try catch block (using the order in which they
+     *            are visited with visitTryCatchBlock).
+     * 
+     * @return a reference to the type of the given exception.
+     */
+    public static TypeReference newTryCatchReference(int tryCatchBlockIndex) {
+        return new TypeReference((EXCEPTION_PARAMETER << 24)
+                | (tryCatchBlockIndex << 8));
+    }
+
+    /**
+     * Returns a reference to the type of a type argument in a constructor or
+     * method call or reference.
+     * 
+     * @param sort
+     *            {@link #CAST CAST},
+     *            {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
+     *            CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
+     *            {@link #METHOD_INVOCATION_TYPE_ARGUMENT
+     *            METHOD_INVOCATION_TYPE_ARGUMENT},
+     *            {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
+     *            CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
+     *            {@link #METHOD_REFERENCE_TYPE_ARGUMENT
+     *            METHOD_REFERENCE_TYPE_ARGUMENT}.
+     * @param argIndex
+     *            the type argument index.
+     * 
+     * @return a reference to the type of the given type argument.
+     */
+    public static TypeReference newTypeArgumentReference(int sort, int argIndex) {
+        return new TypeReference((sort << 24) | argIndex);
+    }
+
+    /**
+     * Returns the sort of this type reference.
+     * 
+     * @return {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
+     *         {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
+     *         {@link #CLASS_EXTENDS CLASS_EXTENDS},
+     *         {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND},
+     *         {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND},
+     *         {@link #FIELD FIELD}, {@link #METHOD_RETURN METHOD_RETURN},
+     *         {@link #METHOD_RECEIVER METHOD_RECEIVER},
+     *         {@link #METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER},
+     *         {@link #THROWS THROWS}, {@link #LOCAL_VARIABLE LOCAL_VARIABLE},
+     *         {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE},
+     *         {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER},
+     *         {@link #INSTANCEOF INSTANCEOF}, {@link #NEW NEW},
+     *         {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE},
+     *         {@link #METHOD_REFERENCE METHOD_REFERENCE}, {@link #CAST CAST},
+     *         {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
+     *         CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
+     *         {@link #METHOD_INVOCATION_TYPE_ARGUMENT
+     *         METHOD_INVOCATION_TYPE_ARGUMENT},
+     *         {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
+     *         CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
+     *         {@link #METHOD_REFERENCE_TYPE_ARGUMENT
+     *         METHOD_REFERENCE_TYPE_ARGUMENT}.
+     */
+    public int getSort() {
+        return value >>> 24;
+    }
+
+    /**
+     * Returns the index of the type parameter referenced by this type
+     * reference. This method must only be used for type references whose sort
+     * is {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
+     * {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
+     * {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
+     * {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND}.
+     * 
+     * @return a type parameter index.
+     */
+    public int getTypeParameterIndex() {
+        return (value & 0x00FF0000) >> 16;
+    }
+
+    /**
+     * Returns the index of the type parameter bound, within the type parameter
+     * {@link #getTypeParameterIndex}, referenced by this type reference. This
+     * method must only be used for type references whose sort is
+     * {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
+     * {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND}.
+     * 
+     * @return a type parameter bound index.
+     */
+    public int getTypeParameterBoundIndex() {
+        return (value & 0x0000FF00) >> 8;
+    }
+
+    /**
+     * Returns the index of the "super type" of a class that is referenced by
+     * this type reference. This method must only be used for type references
+     * whose sort is {@link #CLASS_EXTENDS CLASS_EXTENDS}.
+     * 
+     * @return the index of an interface in the 'implements' clause of a class,
+     *         or -1 if this type reference references the type of the super
+     *         class.
+     */
+    public int getSuperTypeIndex() {
+        return (short) ((value & 0x00FFFF00) >> 8);
+    }
+
+    /**
+     * Returns the index of the formal parameter whose type is referenced by
+     * this type reference. This method must only be used for type references
+     * whose sort is {@link #METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER}.
+     * 
+     * @return a formal parameter index.
+     */
+    public int getFormalParameterIndex() {
+        return (value & 0x00FF0000) >> 16;
+    }
+
+    /**
+     * Returns the index of the exception, in a 'throws' clause of a method,
+     * whose type is referenced by this type reference. This method must only be
+     * used for type references whose sort is {@link #THROWS THROWS}.
+     * 
+     * @return the index of an exception in the 'throws' clause of a method.
+     */
+    public int getExceptionIndex() {
+        return (value & 0x00FFFF00) >> 8;
+    }
+
+    /**
+     * Returns the index of the try catch block (using the order in which they
+     * are visited with visitTryCatchBlock), whose 'catch' type is referenced by
+     * this type reference. This method must only be used for type references
+     * whose sort is {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER} .
+     * 
+     * @return the index of an exception in the 'throws' clause of a method.
+     */
+    public int getTryCatchBlockIndex() {
+        return (value & 0x00FFFF00) >> 8;
+    }
+
+    /**
+     * Returns the index of the type argument referenced by this type reference.
+     * This method must only be used for type references whose sort is
+     * {@link #CAST CAST}, {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
+     * CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
+     * {@link #METHOD_INVOCATION_TYPE_ARGUMENT METHOD_INVOCATION_TYPE_ARGUMENT},
+     * {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
+     * CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
+     * {@link #METHOD_REFERENCE_TYPE_ARGUMENT METHOD_REFERENCE_TYPE_ARGUMENT}.
+     * 
+     * @return a type parameter index.
+     */
+    public int getTypeArgumentIndex() {
+        return value & 0xFF;
+    }
+
+    /**
+     * Returns the int encoded value of this type reference, suitable for use in
+     * visit methods related to type annotations, like visitTypeAnnotation.
+     * 
+     * @return the int encoded value of this type reference.
+     */
+    public int getValue() {
+        return value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0ac605d/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/AdviceAdapter.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/AdviceAdapter.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/AdviceAdapter.java
new file mode 100644
index 0000000..a53995b
--- /dev/null
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/AdviceAdapter.java
@@ -0,0 +1,646 @@
+/***
+ * 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.commons;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.Opcodes;
+import org.apache.tapestry5.internal.plastic.asm.Type;
+
+/**
+ * A {@link org.apache.tapestry5.internal.plastic.asm.MethodVisitor} to insert before, after and around
+ * advices in methods and constructors.
+ * <p>
+ * The behavior for constructors is like this:
+ * <ol>
+ * 
+ * <li>as long as the INVOKESPECIAL for the object initialization has not been
+ * reached, every bytecode instruction is dispatched in the ctor code visitor</li>
+ * 
+ * <li>when this one is reached, it is only added in the ctor code visitor and a
+ * JP invoke is added</li>
+ * 
+ * <li>after that, only the other code visitor receives the instructions</li>
+ * 
+ * </ol>
+ * 
+ * @author Eugene Kuleshov
+ * @author Eric Bruneton
+ */
+public abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes {
+
+    private static final Object THIS = new Object();
+
+    private static final Object OTHER = new Object();
+
+    protected int methodAccess;
+
+    protected String methodDesc;
+
+    private boolean constructor;
+
+    private boolean superInitialized;
+
+    private List<Object> stackFrame;
+
+    private Map<Label, List<Object>> branches;
+
+    /**
+     * Creates a new {@link AdviceAdapter}.
+     * 
+     * @param api
+     *            the ASM API version implemented by this visitor. Must be one
+     *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
+     * @param mv
+     *            the method visitor to which this adapter delegates calls.
+     * @param access
+     *            the method's access flags (see {@link Opcodes}).
+     * @param name
+     *            the method's name.
+     * @param desc
+     *            the method's descriptor (see {@link Type Type}).
+     */
+    protected AdviceAdapter(final int api, final MethodVisitor mv,
+            final int access, final String name, final String desc) {
+        super(api, mv, access, name, desc);
+        methodAccess = access;
+        methodDesc = desc;
+        constructor = "<init>".equals(name);
+    }
+
+    @Override
+    public void visitCode() {
+        mv.visitCode();
+        if (constructor) {
+            stackFrame = new ArrayList<Object>();
+            branches = new HashMap<Label, List<Object>>();
+        } else {
+            superInitialized = true;
+            onMethodEnter();
+        }
+    }
+
+    @Override
+    public void visitLabel(final Label label) {
+        mv.visitLabel(label);
+        if (constructor && branches != null) {
+            List<Object> frame = branches.get(label);
+            if (frame != null) {
+                stackFrame = frame;
+                branches.remove(label);
+            }
+        }
+    }
+
+    @Override
+    public void visitInsn(final int opcode) {
+        if (constructor) {
+            int s;
+            switch (opcode) {
+            case RETURN: // empty stack
+                onMethodExit(opcode);
+                break;
+            case IRETURN: // 1 before n/a after
+            case FRETURN: // 1 before n/a after
+            case ARETURN: // 1 before n/a after
+            case ATHROW: // 1 before n/a after
+                popValue();
+                onMethodExit(opcode);
+                break;
+            case LRETURN: // 2 before n/a after
+            case DRETURN: // 2 before n/a after
+                popValue();
+                popValue();
+                onMethodExit(opcode);
+                break;
+            case NOP:
+            case LALOAD: // remove 2 add 2
+            case DALOAD: // remove 2 add 2
+            case LNEG:
+            case DNEG:
+            case FNEG:
+            case INEG:
+            case L2D:
+            case D2L:
+            case F2I:
+            case I2B:
+            case I2C:
+            case I2S:
+            case I2F:
+            case ARRAYLENGTH:
+                break;
+            case ACONST_NULL:
+            case ICONST_M1:
+            case ICONST_0:
+            case ICONST_1:
+            case ICONST_2:
+            case ICONST_3:
+            case ICONST_4:
+            case ICONST_5:
+            case FCONST_0:
+            case FCONST_1:
+            case FCONST_2:
+            case F2L: // 1 before 2 after
+            case F2D:
+            case I2L:
+            case I2D:
+                pushValue(OTHER);
+                break;
+            case LCONST_0:
+            case LCONST_1:
+            case DCONST_0:
+            case DCONST_1:
+                pushValue(OTHER);
+                pushValue(OTHER);
+                break;
+            case IALOAD: // remove 2 add 1
+            case FALOAD: // remove 2 add 1
+            case AALOAD: // remove 2 add 1
+            case BALOAD: // remove 2 add 1
+            case CALOAD: // remove 2 add 1
+            case SALOAD: // remove 2 add 1
+            case POP:
+            case IADD:
+            case FADD:
+            case ISUB:
+            case LSHL: // 3 before 2 after
+            case LSHR: // 3 before 2 after
+            case LUSHR: // 3 before 2 after
+            case L2I: // 2 before 1 after
+            case L2F: // 2 before 1 after
+            case D2I: // 2 before 1 after
+            case D2F: // 2 before 1 after
+            case FSUB:
+            case FMUL:
+            case FDIV:
+            case FREM:
+            case FCMPL: // 2 before 1 after
+            case FCMPG: // 2 before 1 after
+            case IMUL:
+            case IDIV:
+            case IREM:
+            case ISHL:
+            case ISHR:
+            case IUSHR:
+            case IAND:
+            case IOR:
+            case IXOR:
+            case MONITORENTER:
+            case MONITOREXIT:
+                popValue();
+                break;
+            case POP2:
+            case LSUB:
+            case LMUL:
+            case LDIV:
+            case LREM:
+            case LADD:
+            case LAND:
+            case LOR:
+            case LXOR:
+            case DADD:
+            case DMUL:
+            case DSUB:
+            case DDIV:
+            case DREM:
+                popValue();
+                popValue();
+                break;
+            case IASTORE:
+            case FASTORE:
+            case AASTORE:
+            case BASTORE:
+            case CASTORE:
+            case SASTORE:
+            case LCMP: // 4 before 1 after
+            case DCMPL:
+            case DCMPG:
+                popValue();
+                popValue();
+                popValue();
+                break;
+            case LASTORE:
+            case DASTORE:
+                popValue();
+                popValue();
+                popValue();
+                popValue();
+                break;
+            case DUP:
+                pushValue(peekValue());
+                break;
+            case DUP_X1:
+                s = stackFrame.size();
+                stackFrame.add(s - 2, stackFrame.get(s - 1));
+                break;
+            case DUP_X2:
+                s = stackFrame.size();
+                stackFrame.add(s - 3, stackFrame.get(s - 1));
+                break;
+            case DUP2:
+                s = stackFrame.size();
+                stackFrame.add(s - 2, stackFrame.get(s - 1));
+                stackFrame.add(s - 2, stackFrame.get(s - 1));
+                break;
+            case DUP2_X1:
+                s = stackFrame.size();
+                stackFrame.add(s - 3, stackFrame.get(s - 1));
+                stackFrame.add(s - 3, stackFrame.get(s - 1));
+                break;
+            case DUP2_X2:
+                s = stackFrame.size();
+                stackFrame.add(s - 4, stackFrame.get(s - 1));
+                stackFrame.add(s - 4, stackFrame.get(s - 1));
+                break;
+            case SWAP:
+                s = stackFrame.size();
+                stackFrame.add(s - 2, stackFrame.get(s - 1));
+                stackFrame.remove(s);
+                break;
+            }
+        } else {
+            switch (opcode) {
+            case RETURN:
+            case IRETURN:
+            case FRETURN:
+            case ARETURN:
+            case LRETURN:
+            case DRETURN:
+            case ATHROW:
+                onMethodExit(opcode);
+                break;
+            }
+        }
+        mv.visitInsn(opcode);
+    }
+
+    @Override
+    public void visitVarInsn(final int opcode, final int var) {
+        super.visitVarInsn(opcode, var);
+        if (constructor) {
+            switch (opcode) {
+            case ILOAD:
+            case FLOAD:
+                pushValue(OTHER);
+                break;
+            case LLOAD:
+            case DLOAD:
+                pushValue(OTHER);
+                pushValue(OTHER);
+                break;
+            case ALOAD:
+                pushValue(var == 0 ? THIS : OTHER);
+                break;
+            case ASTORE:
+            case ISTORE:
+            case FSTORE:
+                popValue();
+                break;
+            case LSTORE:
+            case DSTORE:
+                popValue();
+                popValue();
+                break;
+            }
+        }
+    }
+
+    @Override
+    public void visitFieldInsn(final int opcode, final String owner,
+            final String name, final String desc) {
+        mv.visitFieldInsn(opcode, owner, name, desc);
+        if (constructor) {
+            char c = desc.charAt(0);
+            boolean longOrDouble = c == 'J' || c == 'D';
+            switch (opcode) {
+            case GETSTATIC:
+                pushValue(OTHER);
+                if (longOrDouble) {
+                    pushValue(OTHER);
+                }
+                break;
+            case PUTSTATIC:
+                popValue();
+                if (longOrDouble) {
+                    popValue();
+                }
+                break;
+            case PUTFIELD:
+                popValue();
+                if (longOrDouble) {
+                    popValue();
+                    popValue();
+                }
+                break;
+            // case GETFIELD:
+            default:
+                if (longOrDouble) {
+                    pushValue(OTHER);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void visitIntInsn(final int opcode, final int operand) {
+        mv.visitIntInsn(opcode, operand);
+        if (constructor && opcode != NEWARRAY) {
+            pushValue(OTHER);
+        }
+    }
+
+    @Override
+    public void visitLdcInsn(final Object cst) {
+        mv.visitLdcInsn(cst);
+        if (constructor) {
+            pushValue(OTHER);
+            if (cst instanceof Double || cst instanceof Long) {
+                pushValue(OTHER);
+            }
+        }
+    }
+
+    @Override
+    public void visitMultiANewArrayInsn(final String desc, final int dims) {
+        mv.visitMultiANewArrayInsn(desc, dims);
+        if (constructor) {
+            for (int i = 0; i < dims; i++) {
+                popValue();
+            }
+            pushValue(OTHER);
+        }
+    }
+
+    @Override
+    public void visitTypeInsn(final int opcode, final String type) {
+        mv.visitTypeInsn(opcode, type);
+        // ANEWARRAY, CHECKCAST or INSTANCEOF don't change stack
+        if (constructor && opcode == NEW) {
+            pushValue(OTHER);
+        }
+    }
+
+    @Deprecated
+    @Override
+    public void visitMethodInsn(final int opcode, final String owner,
+            final String name, final String desc) {
+        if (api >= Opcodes.ASM5) {
+            super.visitMethodInsn(opcode, owner, name, desc);
+            return;
+        }
+        doVisitMethodInsn(opcode, owner, name, desc,
+                opcode == Opcodes.INVOKEINTERFACE);
+    }
+
+    @Override
+    public void visitMethodInsn(final int opcode, final String owner,
+            final String name, final String desc, final boolean itf) {
+        if (api < Opcodes.ASM5) {
+            super.visitMethodInsn(opcode, owner, name, desc, itf);
+            return;
+        }
+        doVisitMethodInsn(opcode, owner, name, desc, itf);
+    }
+
+    private void doVisitMethodInsn(int opcode, final String owner,
+            final String name, final String desc, final boolean itf) {
+        mv.visitMethodInsn(opcode, owner, name, desc, itf);
+        if (constructor) {
+            Type[] types = Type.getArgumentTypes(desc);
+            for (int i = 0; i < types.length; i++) {
+                popValue();
+                if (types[i].getSize() == 2) {
+                    popValue();
+                }
+            }
+            switch (opcode) {
+            // case INVOKESTATIC:
+            // break;
+            case INVOKEINTERFACE:
+            case INVOKEVIRTUAL:
+                popValue(); // objectref
+                break;
+            case INVOKESPECIAL:
+                Object type = popValue(); // objectref
+                if (type == THIS && !superInitialized) {
+                    onMethodEnter();
+                    superInitialized = true;
+                    // once super has been initialized it is no longer
+                    // necessary to keep track of stack state
+                    constructor = false;
+                }
+                break;
+            }
+
+            Type returnType = Type.getReturnType(desc);
+            if (returnType != Type.VOID_TYPE) {
+                pushValue(OTHER);
+                if (returnType.getSize() == 2) {
+                    pushValue(OTHER);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
+            Object... bsmArgs) {
+        mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
+        if (constructor) {
+            Type[] types = Type.getArgumentTypes(desc);
+            for (int i = 0; i < types.length; i++) {
+                popValue();
+                if (types[i].getSize() == 2) {
+                    popValue();
+                }
+            }
+
+            Type returnType = Type.getReturnType(desc);
+            if (returnType != Type.VOID_TYPE) {
+                pushValue(OTHER);
+                if (returnType.getSize() == 2) {
+                    pushValue(OTHER);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void visitJumpInsn(final int opcode, final Label label) {
+        mv.visitJumpInsn(opcode, label);
+        if (constructor) {
+            switch (opcode) {
+            case IFEQ:
+            case IFNE:
+            case IFLT:
+            case IFGE:
+            case IFGT:
+            case IFLE:
+            case IFNULL:
+            case IFNONNULL:
+                popValue();
+                break;
+            case IF_ICMPEQ:
+            case IF_ICMPNE:
+            case IF_ICMPLT:
+            case IF_ICMPGE:
+            case IF_ICMPGT:
+            case IF_ICMPLE:
+            case IF_ACMPEQ:
+            case IF_ACMPNE:
+                popValue();
+                popValue();
+                break;
+            case JSR:
+                pushValue(OTHER);
+                break;
+            }
+            addBranch(label);
+        }
+    }
+
+    @Override
+    public void visitLookupSwitchInsn(final Label dflt, final int[] keys,
+            final Label[] labels) {
+        mv.visitLookupSwitchInsn(dflt, keys, labels);
+        if (constructor) {
+            popValue();
+            addBranches(dflt, labels);
+        }
+    }
+
+    @Override
+    public void visitTableSwitchInsn(final int min, final int max,
+            final Label dflt, final Label... labels) {
+        mv.visitTableSwitchInsn(min, max, dflt, labels);
+        if (constructor) {
+            popValue();
+            addBranches(dflt, labels);
+        }
+    }
+
+    @Override
+    public void visitTryCatchBlock(Label start, Label end, Label handler,
+            String type) {
+        super.visitTryCatchBlock(start, end, handler, type);
+        if (constructor && !branches.containsKey(handler)) {
+            List<Object> stackFrame = new ArrayList<Object>();
+            stackFrame.add(OTHER);
+            branches.put(handler, stackFrame);
+        }
+    }
+
+    private void addBranches(final Label dflt, final Label[] labels) {
+        addBranch(dflt);
+        for (int i = 0; i < labels.length; i++) {
+            addBranch(labels[i]);
+        }
+    }
+
+    private void addBranch(final Label label) {
+        if (branches.containsKey(label)) {
+            return;
+        }
+        branches.put(label, new ArrayList<Object>(stackFrame));
+    }
+
+    private Object popValue() {
+        return stackFrame.remove(stackFrame.size() - 1);
+    }
+
+    private Object peekValue() {
+        return stackFrame.get(stackFrame.size() - 1);
+    }
+
+    private void pushValue(final Object o) {
+        stackFrame.add(o);
+    }
+
+    /**
+     * Called at the beginning of the method or after super class class call in
+     * the constructor. <br>
+     * <br>
+     * 
+     * <i>Custom code can use or change all the local variables, but should not
+     * change state of the stack.</i>
+     */
+    protected void onMethodEnter() {
+    }
+
+    /**
+     * Called before explicit exit from the method using either return or throw.
+     * Top element on the stack contains the return value or exception instance.
+     * For example:
+     * 
+     * <pre>
+     *   public void onMethodExit(int opcode) {
+     *     if(opcode==RETURN) {
+     *         visitInsn(ACONST_NULL);
+     *     } else if(opcode==ARETURN || opcode==ATHROW) {
+     *         dup();
+     *     } else {
+     *         if(opcode==LRETURN || opcode==DRETURN) {
+     *             dup2();
+     *         } else {
+     *             dup();
+     *         }
+     *         box(Type.getReturnType(this.methodDesc));
+     *     }
+     *     visitIntInsn(SIPUSH, opcode);
+     *     visitMethodInsn(INVOKESTATIC, owner, "onExit", "(Ljava/lang/Object;I)V");
+     *   }
+     * 
+     *   // an actual call back method
+     *   public static void onExit(Object param, int opcode) {
+     *     ...
+     * </pre>
+     * 
+     * <br>
+     * <br>
+     * 
+     * <i>Custom code can use or change all the local variables, but should not
+     * change state of the stack.</i>
+     * 
+     * @param opcode
+     *            one of the RETURN, IRETURN, FRETURN, ARETURN, LRETURN, DRETURN
+     *            or ATHROW
+     * 
+     */
+    protected void onMethodExit(int opcode) {
+    }
+
+    // TODO onException, onMethodCall
+}