You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/05/30 21:20:36 UTC
[1/17] git commit: TAP5-1852: Upgrade Plastic to use ASM 4.0 - Remove
unused utility classes
Updated Branches:
refs/heads/master 9b4a8e12b -> d6e5f4131
TAP5-1852: Upgrade Plastic to use ASM 4.0
- Remove unused utility classes
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/d6e5f413
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/d6e5f413
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/d6e5f413
Branch: refs/heads/master
Commit: d6e5f4131d62f588b6eeade7a3f16235a5766305
Parents: 9b4a8e1
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed May 30 11:57:14 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed May 30 11:57:45 2012 -0700
----------------------------------------------------------------------
.../internal/plastic/asm/AnnotationVisitor.java | 100 +-
.../internal/plastic/asm/AnnotationWriter.java | 26 +-
.../tapestry5/internal/plastic/asm/Attribute.java | 22 +-
.../tapestry5/internal/plastic/asm/ByteVector.java | 24 +-
.../internal/plastic/asm/ClassAdapter.java | 121 --
.../internal/plastic/asm/ClassReader.java | 340 +++-
.../internal/plastic/asm/ClassVisitor.java | 133 +-
.../internal/plastic/asm/ClassWriter.java | 423 ++++-
.../tapestry5/internal/plastic/asm/Edge.java | 4 +-
.../internal/plastic/asm/FieldVisitor.java | 69 +-
.../internal/plastic/asm/FieldWriter.java | 25 +-
.../tapestry5/internal/plastic/asm/Frame.java | 66 +-
.../tapestry5/internal/plastic/asm/Handle.java | 159 ++
.../tapestry5/internal/plastic/asm/Handler.java | 52 +-
.../tapestry5/internal/plastic/asm/Item.java | 71 +-
.../tapestry5/internal/plastic/asm/Label.java | 53 +-
.../internal/plastic/asm/MethodAdapter.java | 195 --
.../internal/plastic/asm/MethodVisitor.java | 321 +++-
.../internal/plastic/asm/MethodWriter.java | 170 ++-
.../tapestry5/internal/plastic/asm/Opcodes.java | 27 +-
.../tapestry5/internal/plastic/asm/Type.java | 213 ++-
.../internal/plastic/asm/attrs/package.html | 8 +-
.../plastic/asm/commons/AdviceAdapter.java | 613 ------
.../plastic/asm/commons/AnalyzerAdapter.java | 877 ---------
.../plastic/asm/commons/CodeSizeEvaluator.java | 206 --
.../internal/plastic/asm/commons/EmptyVisitor.java | 238 ---
.../plastic/asm/commons/GeneratorAdapter.java | 1506 ---------------
.../plastic/asm/commons/InstructionAdapter.java | 1079 -----------
.../plastic/asm/commons/JSRInlinerAdapter.java | 207 +-
.../plastic/asm/commons/LocalVariablesSorter.java | 318 ---
.../internal/plastic/asm/commons/Method.java | 275 ---
.../internal/plastic/asm/commons/Remapper.java | 187 --
.../asm/commons/RemappingAnnotationAdapter.java | 76 -
.../plastic/asm/commons/RemappingClassAdapter.java | 145 --
.../plastic/asm/commons/RemappingFieldAdapter.java | 65 -
.../asm/commons/RemappingMethodAdapter.java | 168 --
.../asm/commons/RemappingSignatureAdapter.java | 126 --
.../plastic/asm/commons/SerialVersionUIDAdder.java | 499 -----
.../plastic/asm/commons/SimpleRemapper.java | 62 -
.../plastic/asm/commons/StaticInitMerger.java | 99 -
.../plastic/asm/commons/TableSwitchGenerator.java | 55 -
.../plastic/asm/commons/TryCatchBlockSorter.java | 60 -
.../internal/plastic/asm/commons/package.html | 48 -
.../optimizer/AnnotationConstantsCollector.java | 150 --
.../asm/optimizer/ClassConstantsCollector.java | 208 --
.../plastic/asm/optimizer/ClassOptimizer.java | 172 --
.../internal/plastic/asm/optimizer/Constant.java | 265 ---
.../plastic/asm/optimizer/ConstantPool.java | 198 --
.../asm/optimizer/FieldConstantsCollector.java | 76 -
.../plastic/asm/optimizer/JarOptimizer.java | 231 ---
.../asm/optimizer/MethodConstantsCollector.java | 168 --
.../plastic/asm/optimizer/MethodOptimizer.java | 103 -
.../plastic/asm/optimizer/NameMapping.java | 111 --
.../internal/plastic/asm/optimizer/Shrinker.java | 196 --
.../plastic/asm/optimizer/jdk1.2.2_017.txt.gz | Bin 113814 -> 0 bytes
.../plastic/asm/optimizer/jdk1.3.1_19.txt.gz | Bin 128067 -> 0 bytes
.../asm/optimizer/shrink-annotations.properties | 23 -
.../plastic/asm/optimizer/shrink-frames.properties | 32 -
.../plastic/asm/optimizer/shrink-resize.properties | 7 -
.../asm/optimizer/shrink-signatures.properties | 13 -
.../plastic/asm/optimizer/shrink-writer.properties | 38 -
.../plastic/asm/optimizer/shrink.properties | 282 ---
.../tapestry5/internal/plastic/asm/package.html | 32 +-
.../plastic/asm/signature/SignatureReader.java | 16 +-
.../plastic/asm/signature/SignatureVisitor.java | 123 +-
.../plastic/asm/signature/SignatureWriter.java | 28 +-
.../internal/plastic/asm/signature/package.html | 2 +-
.../plastic/asm/tree/AbstractInsnNode.java | 59 +-
.../internal/plastic/asm/tree/AnnotationNode.java | 72 +-
.../internal/plastic/asm/tree/ClassNode.java | 148 ++-
.../internal/plastic/asm/tree/FieldInsnNode.java | 17 +-
.../internal/plastic/asm/tree/FieldNode.java | 144 ++-
.../internal/plastic/asm/tree/FrameNode.java | 51 +-
.../internal/plastic/asm/tree/IincInsnNode.java | 15 +-
.../internal/plastic/asm/tree/InnerClassNode.java | 8 +-
.../internal/plastic/asm/tree/InsnList.java | 152 +-
.../internal/plastic/asm/tree/InsnNode.java | 17 +-
.../internal/plastic/asm/tree/IntInsnNode.java | 17 +-
.../plastic/asm/tree/InvokeDynamicInsnNode.java | 100 +
.../internal/plastic/asm/tree/JumpInsnNode.java | 17 +-
.../internal/plastic/asm/tree/LabelNode.java | 13 +-
.../internal/plastic/asm/tree/LdcInsnNode.java | 15 +-
.../internal/plastic/asm/tree/LineNumberNode.java | 15 +-
.../plastic/asm/tree/LocalVariableNode.java | 8 +-
.../plastic/asm/tree/LookupSwitchInsnNode.java | 25 +-
.../internal/plastic/asm/tree/MemberNode.java | 120 --
.../internal/plastic/asm/tree/MethodInsnNode.java | 24 +-
.../internal/plastic/asm/tree/MethodNode.java | 265 ++-
.../plastic/asm/tree/MultiANewArrayInsnNode.java | 15 +-
.../plastic/asm/tree/TableSwitchInsnNode.java | 19 +-
.../plastic/asm/tree/TryCatchBlockNode.java | 8 +-
.../internal/plastic/asm/tree/TypeInsnNode.java | 17 +-
.../internal/plastic/asm/tree/VarInsnNode.java | 17 +-
.../plastic/asm/tree/analysis/Analyzer.java | 523 -----
.../asm/tree/analysis/AnalyzerException.java | 64 -
.../asm/tree/analysis/BasicInterpreter.java | 330 ----
.../plastic/asm/tree/analysis/BasicValue.java | 105 -
.../plastic/asm/tree/analysis/BasicVerifier.java | 441 -----
.../internal/plastic/asm/tree/analysis/Frame.java | 693 -------
.../plastic/asm/tree/analysis/Interpreter.java | 192 --
.../plastic/asm/tree/analysis/SimpleVerifier.java | 309 ---
.../plastic/asm/tree/analysis/SmallSet.java | 126 --
.../asm/tree/analysis/SourceInterpreter.java | 184 --
.../plastic/asm/tree/analysis/SourceValue.java | 95 -
.../plastic/asm/tree/analysis/Subroutine.java | 93 -
.../internal/plastic/asm/tree/analysis/Value.java | 45 -
.../plastic/asm/tree/analysis/package.html | 67 -
.../internal/plastic/asm/tree/package.html | 74 +-
.../internal/plastic/asm/util/ASMifiable.java | 18 +-
.../plastic/asm/util/ASMifierAbstractVisitor.java | 222 ---
.../asm/util/ASMifierAnnotationVisitor.java | 127 --
.../plastic/asm/util/ASMifierClassVisitor.java | 575 ------
.../plastic/asm/util/ASMifierFieldVisitor.java | 50 -
.../plastic/asm/util/ASMifierMethodVisitor.java | 443 -----
.../internal/plastic/asm/util/AbstractVisitor.java | 202 --
.../plastic/asm/util/CheckAnnotationAdapter.java | 132 --
.../plastic/asm/util/CheckClassAdapter.java | 569 ------
.../plastic/asm/util/CheckFieldAdapter.java | 77 -
.../plastic/asm/util/CheckMethodAdapter.java | 1498 --------------
.../plastic/asm/util/CheckSignatureAdapter.java | 290 ---
.../internal/plastic/asm/util/Printer.java | 558 ++++++
.../internal/plastic/asm/util/Textifiable.java | 54 +
.../internal/plastic/asm/util/Textifier.java | 1281 ++++++++++++
.../plastic/asm/util/TraceAbstractVisitor.java | 179 --
.../plastic/asm/util/TraceAnnotationVisitor.java | 237 +--
.../plastic/asm/util/TraceClassVisitor.java | 485 +----
.../plastic/asm/util/TraceFieldVisitor.java | 48 +-
.../plastic/asm/util/TraceMethodVisitor.java | 513 +----
.../plastic/asm/util/TraceSignatureVisitor.java | 27 +-
.../internal/plastic/asm/util/Traceable.java | 52 -
.../internal/plastic/asm/util/package.html | 2 +-
.../plastic/asm/xml/ASMContentHandler.java | 1279 ------------
.../internal/plastic/asm/xml/Processor.java | 1073 ----------
.../internal/plastic/asm/xml/SAXAdapter.java | 94 -
.../plastic/asm/xml/SAXAnnotationAdapter.java | 218 ---
.../internal/plastic/asm/xml/SAXClassAdapter.java | 349 ----
.../internal/plastic/asm/xml/SAXCodeAdapter.java | 397 ----
.../internal/plastic/asm/xml/SAXFieldAdapter.java | 63 -
.../tapestry5/internal/plastic/asm/xml/asm-xml.dtd | 343 ----
.../internal/plastic/asm/xml/package.html | 96 -
.../plastic/AbstractAnnotationBuilder.java | 13 +-
.../internal/plastic/MethodAdviceManager.java | 20 +-
.../internal/plastic/PlasticClassImpl.java | 6 +-
.../internal/plastic/PlasticClassPool.java | 2 +-
.../internal/plastic/PlasticInternalUtils.java | 4 +-
.../internal/AbstractReloadableObjectCreator.java | 5 +-
146 files changed, 5155 insertions(+), 23170 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationVisitor.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationVisitor.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationVisitor.java
index fe472cd..693b355 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationVisitor.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationVisitor.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,41 +30,87 @@
package org.apache.tapestry5.internal.plastic.asm;
/**
- * A visitor to visit a Java annotation. The methods of this interface must be
- * called in the following order: (<tt>visit<tt> | <tt>visitEnum<tt> |
- * <tt>visitAnnotation<tt> | <tt>visitArray<tt>)* <tt>visitEnd<tt>.
+ * A visitor to visit a Java annotation. The methods of this class must be
+ * called in the following order: ( <tt>visit</tt> | <tt>visitEnum</tt> |
+ * <tt>visitAnnotation</tt> | <tt>visitArray</tt> )* <tt>visitEnd</tt>.
*
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
-public interface AnnotationVisitor {
+public abstract class AnnotationVisitor {
+
+ /**
+ * The ASM API version implemented by this visitor. The value of this field
+ * must be one of {@link Opcodes#ASM4}.
+ */
+ protected final int api;
+
+ /**
+ * The annotation visitor to which this visitor must delegate method calls.
+ * May be null.
+ */
+ protected AnnotationVisitor av;
+
+ /**
+ * Constructs a new {@link AnnotationVisitor}.
+ *
+ * @param api the ASM API version implemented by this visitor. Must be one
+ * of {@link Opcodes#ASM4}.
+ */
+ public AnnotationVisitor(final int api) {
+ this(api, null);
+ }
+
+ /**
+ * Constructs a new {@link AnnotationVisitor}.
+ *
+ * @param api the ASM API version implemented by this visitor. Must be one
+ * of {@link Opcodes#ASM4}.
+ * @param av the annotation visitor to which this visitor must delegate
+ * method calls. May be null.
+ */
+ public AnnotationVisitor(final int api, final AnnotationVisitor av) {
+ /*if (api != Opcodes.ASM4) {
+ throw new IllegalArgumentException();
+ }*/
+ this.api = api;
+ this.av = av;
+ }
/**
* Visits a primitive value of the annotation.
- *
+ *
* @param name the value name.
* @param value the actual value, whose type must be {@link Byte},
- * {@link Boolean}, {@link Character}, {@link Short},
- * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
- * {@link String} or {@link Type}. This value can also be an array
- * of byte, boolean, short, char, int, long, float or double values
- * (this is equivalent to using {@link #visitArray visitArray} and
- * visiting each array element in turn, but is more convenient).
+ * {@link Boolean}, {@link Character}, {@link Short}, {@link Integer}
+ * , {@link Long}, {@link Float}, {@link Double}, {@link String} or
+ * {@link Type} or OBJECT or ARRAY sort. This value can also be an
+ * array of byte, boolean, short, char, int, long, float or double
+ * values (this is equivalent to using {@link #visitArray visitArray}
+ * and visiting each array element in turn, but is more convenient).
*/
- void visit(String name, Object value);
+ public void visit(String name, Object value) {
+ if (av != null) {
+ av.visit(name, value);
+ }
+ }
/**
* Visits an enumeration value of the annotation.
- *
+ *
* @param name the value name.
* @param desc the class descriptor of the enumeration class.
* @param value the actual enumeration value.
*/
- void visitEnum(String name, String desc, String value);
+ public void visitEnum(String name, String desc, String value) {
+ if (av != null) {
+ av.visitEnum(name, desc, value);
+ }
+ }
/**
* Visits a nested annotation value of the annotation.
- *
+ *
* @param name the value name.
* @param desc the class descriptor of the nested annotation class.
* @return a visitor to visit the actual nested annotation value, or
@@ -73,14 +119,19 @@ public interface AnnotationVisitor {
* fully visited before calling other methods on this annotation
* visitor</i>.
*/
- AnnotationVisitor visitAnnotation(String name, String desc);
+ public AnnotationVisitor visitAnnotation(String name, String desc) {
+ if (av != null) {
+ return av.visitAnnotation(name, desc);
+ }
+ return null;
+ }
/**
* Visits an array value of the annotation. Note that arrays of primitive
* types (such as byte, boolean, short, char, int, long, float or double)
* can be passed as value to {@link #visit visit}. This is what
* {@link ClassReader} does.
- *
+ *
* @param name the value name.
* @return a visitor to visit the actual array value elements, or
* <tt>null</tt> if this visitor is not interested in visiting
@@ -88,10 +139,19 @@ public interface AnnotationVisitor {
* visitor are ignored. <i>All the array values must be visited
* before calling other methods on this annotation visitor</i>.
*/
- AnnotationVisitor visitArray(String name);
+ public AnnotationVisitor visitArray(String name) {
+ if (av != null) {
+ return av.visitArray(name);
+ }
+ return null;
+ }
/**
* Visits the end of the annotation.
*/
- void visitEnd();
+ public void visitEnd() {
+ if (av != null) {
+ av.visitEnd();
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationWriter.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationWriter.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationWriter.java
index d16fd2c..a26f5ca 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationWriter.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/AnnotationWriter.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,11 +31,11 @@ package org.apache.tapestry5.internal.plastic.asm;
/**
* An {@link AnnotationVisitor} that generates annotations in bytecode form.
- *
+ *
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
-final class AnnotationWriter implements AnnotationVisitor {
+final class AnnotationWriter extends AnnotationVisitor {
/**
* The class writer to which this annotation must be added.
@@ -48,7 +48,7 @@ final class AnnotationWriter implements AnnotationVisitor {
private int size;
/**
- * <tt>true<tt> if values are named, <tt>false</tt> otherwise. Annotation
+ * <tt>true<tt> if values are named, <tt>false</tt> otherwise. Annotation
* writers used for annotation default and annotation arrays use unnamed
* values.
*/
@@ -89,12 +89,12 @@ final class AnnotationWriter implements AnnotationVisitor {
/**
* Constructs a new {@link AnnotationWriter}.
- *
+ *
* @param cw the class writer to which this annotation must be added.
* @param named <tt>true<tt> if values are named, <tt>false</tt> otherwise.
* @param bv where the annotation values must be stored.
* @param parent where the number of annotation values must be stored.
- * @param offset where in <tt>parent</tt> the number of annotation values must
+ * @param offset where in <tt>parent</tt> the number of annotation values must
* be stored.
*/
AnnotationWriter(
@@ -104,6 +104,7 @@ final class AnnotationWriter implements AnnotationVisitor {
final ByteVector parent,
final int offset)
{
+ super(Opcodes.ASM4);
this.cw = cw;
this.named = named;
this.bv = bv;
@@ -112,9 +113,10 @@ final class AnnotationWriter implements AnnotationVisitor {
}
// ------------------------------------------------------------------------
- // Implementation of the AnnotationVisitor interface
+ // Implementation of the AnnotationVisitor abstract class
// ------------------------------------------------------------------------
+ @Override
public void visit(final String name, final Object value) {
++size;
if (named) {
@@ -187,6 +189,7 @@ final class AnnotationWriter implements AnnotationVisitor {
}
}
+ @Override
public void visitEnum(
final String name,
final String desc,
@@ -199,6 +202,7 @@ final class AnnotationWriter implements AnnotationVisitor {
bv.put12('e', cw.newUTF8(desc)).putShort(cw.newUTF8(value));
}
+ @Override
public AnnotationVisitor visitAnnotation(
final String name,
final String desc)
@@ -212,6 +216,7 @@ final class AnnotationWriter implements AnnotationVisitor {
return new AnnotationWriter(cw, true, bv, bv, bv.length - 2);
}
+ @Override
public AnnotationVisitor visitArray(final String name) {
++size;
if (named) {
@@ -222,6 +227,7 @@ final class AnnotationWriter implements AnnotationVisitor {
return new AnnotationWriter(cw, false, bv, bv, bv.length - 2);
}
+ @Override
public void visitEnd() {
if (parent != null) {
byte[] data = parent.data;
@@ -236,7 +242,7 @@ final class AnnotationWriter implements AnnotationVisitor {
/**
* Returns the size of this annotation writer list.
- *
+ *
* @return the size of this annotation writer list.
*/
int getSize() {
@@ -252,7 +258,7 @@ final class AnnotationWriter implements AnnotationVisitor {
/**
* Puts the annotations of this annotation writer list into the given byte
* vector.
- *
+ *
* @param out where the annotations must be put.
*/
void put(final ByteVector out) {
@@ -279,7 +285,7 @@ final class AnnotationWriter implements AnnotationVisitor {
/**
* Puts the given annotation lists into the given byte vector.
- *
+ *
* @param panns an array of annotation writer lists.
* @param off index of the first annotation to be written.
* @param out where the annotations must be put.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Attribute.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Attribute.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Attribute.java
index 0726034..8f29872 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Attribute.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/Attribute.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,7 @@ package org.apache.tapestry5.internal.plastic.asm;
/**
* A non standard class, field, method or code attribute.
- *
+ *
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
@@ -54,7 +54,7 @@ public class Attribute {
/**
* Constructs a new empty attribute.
- *
+ *
* @param type the type of the attribute.
*/
protected Attribute(final String type) {
@@ -64,7 +64,7 @@ public class Attribute {
/**
* Returns <tt>true</tt> if this type of attribute is unknown. The default
* implementation of this method always returns <tt>true</tt>.
- *
+ *
* @return <tt>true</tt> if this type of attribute is unknown.
*/
public boolean isUnknown() {
@@ -73,7 +73,7 @@ public class Attribute {
/**
* Returns <tt>true</tt> if this type of attribute is a code attribute.
- *
+ *
* @return <tt>true</tt> if this type of attribute is a code attribute.
*/
public boolean isCodeAttribute() {
@@ -82,7 +82,7 @@ public class Attribute {
/**
* Returns the labels corresponding to this attribute.
- *
+ *
* @return the labels corresponding to this attribute, or <tt>null</tt> if
* this attribute is not a code attribute that contains labels.
*/
@@ -95,7 +95,7 @@ public class Attribute {
* {@link Attribute} object, of type {@link #type type}, corresponding to
* the <tt>len</tt> bytes starting at the given offset, in the given class
* reader.
- *
+ *
* @param cr the class that contains the attribute to be read.
* @param off index of the first byte of the attribute's content in {@link
* ClassReader#b cr.b}. The 6 attribute header bytes, containing the
@@ -132,7 +132,7 @@ public class Attribute {
/**
* Returns the byte array form of this attribute.
- *
+ *
* @param cw the class to which this attribute must be added. This parameter
* can be used to add to the constant pool of this class the items
* that corresponds to this attribute.
@@ -165,7 +165,7 @@ public class Attribute {
/**
* Returns the length of the attribute list that begins with this attribute.
- *
+ *
* @return the length of the attribute list that begins with this attribute.
*/
final int getCount() {
@@ -180,7 +180,7 @@ public class Attribute {
/**
* Returns the size of all the attributes in this attribute list.
- *
+ *
* @param cw the class writer to be used to convert the attributes into byte
* arrays, with the {@link #write write} method.
* @param code the bytecode of the method corresponding to these code
@@ -218,7 +218,7 @@ public class Attribute {
/**
* Writes all the attributes of this attribute list in the given byte
* vector.
- *
+ *
* @param cw the class writer to be used to convert the attributes into byte
* arrays, with the {@link #write write} method.
* @param code the bytecode of the method corresponding to these code
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ByteVector.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ByteVector.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ByteVector.java
index df0f07f..e689d87 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ByteVector.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ByteVector.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,7 @@ package org.apache.tapestry5.internal.plastic.asm;
/**
* A dynamically extensible vector of bytes. This class is roughly equivalent to
* a DataOutputStream on top of a ByteArrayOutputStream, but is more efficient.
- *
+ *
* @author Eric Bruneton
*/
public class ByteVector {
@@ -58,7 +58,7 @@ public class ByteVector {
/**
* Constructs a new {@link ByteVector ByteVector} with the given initial
* size.
- *
+ *
* @param initialSize the initial size of the byte vector to be constructed.
*/
public ByteVector(final int initialSize) {
@@ -68,7 +68,7 @@ public class ByteVector {
/**
* Puts a byte into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param b a byte.
* @return this byte vector.
*/
@@ -85,7 +85,7 @@ public class ByteVector {
/**
* Puts two bytes into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param b1 a byte.
* @param b2 another byte.
* @return this byte vector.
@@ -105,7 +105,7 @@ public class ByteVector {
/**
* Puts a short into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param s a short.
* @return this byte vector.
*/
@@ -124,7 +124,7 @@ public class ByteVector {
/**
* Puts a byte and a short into this byte vector. The byte vector is
* automatically enlarged if necessary.
- *
+ *
* @param b a byte.
* @param s a short.
* @return this byte vector.
@@ -145,7 +145,7 @@ public class ByteVector {
/**
* Puts an int into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param i an int.
* @return this byte vector.
*/
@@ -166,7 +166,7 @@ public class ByteVector {
/**
* Puts a long into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param l a long.
* @return this byte vector.
*/
@@ -193,7 +193,7 @@ public class ByteVector {
/**
* Puts an UTF8 string into this byte vector. The byte vector is
* automatically enlarged if necessary.
- *
+ *
* @param s a String.
* @return this byte vector.
*/
@@ -258,7 +258,7 @@ public class ByteVector {
/**
* Puts an array of bytes into this byte vector. The byte vector is
* automatically enlarged if necessary.
- *
+ *
* @param b an array of bytes. May be <tt>null</tt> to put <tt>len</tt>
* null bytes into this byte vector.
* @param off index of the fist byte of b that must be copied.
@@ -279,7 +279,7 @@ public class ByteVector {
/**
* Enlarge this byte vector so that it can receive n more bytes.
- *
+ *
* @param size number of additional bytes that this byte vector should be
* able to receive.
*/
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassAdapter.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassAdapter.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassAdapter.java
deleted file mode 100644
index 5c51eda..0000000
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassAdapter.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 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;
-
-/**
- * An empty {@link ClassVisitor} that delegates to another {@link ClassVisitor}.
- * This class can be used as a super class to quickly implement usefull class
- * adapter classes, just by overriding the necessary methods.
- *
- * @author Eric Bruneton
- */
-public class ClassAdapter implements ClassVisitor {
-
- /**
- * The {@link ClassVisitor} to which this adapter delegates calls.
- */
- protected ClassVisitor cv;
-
- /**
- * Constructs a new {@link ClassAdapter} object.
- *
- * @param cv the class visitor to which this adapter must delegate calls.
- */
- public ClassAdapter(final ClassVisitor cv) {
- this.cv = cv;
- }
-
- public void visit(
- final int version,
- final int access,
- final String name,
- final String signature,
- final String superName,
- final String[] interfaces)
- {
- cv.visit(version, access, name, signature, superName, interfaces);
- }
-
- public void visitSource(final String source, final String debug) {
- cv.visitSource(source, debug);
- }
-
- public void visitOuterClass(
- final String owner,
- final String name,
- final String desc)
- {
- cv.visitOuterClass(owner, name, desc);
- }
-
- public AnnotationVisitor visitAnnotation(
- final String desc,
- final boolean visible)
- {
- return cv.visitAnnotation(desc, visible);
- }
-
- public void visitAttribute(final Attribute attr) {
- cv.visitAttribute(attr);
- }
-
- public void visitInnerClass(
- final String name,
- final String outerName,
- final String innerName,
- final int access)
- {
- cv.visitInnerClass(name, outerName, innerName, access);
- }
-
- public FieldVisitor visitField(
- final int access,
- final String name,
- final String desc,
- final String signature,
- final Object value)
- {
- return cv.visitField(access, name, desc, signature, value);
- }
-
- public MethodVisitor visitMethod(
- final int access,
- final String name,
- final String desc,
- final String signature,
- final String[] exceptions)
- {
- return cv.visitMethod(access, name, desc, signature, exceptions);
- }
-
- public void visitEnd() {
- cv.visitEnd();
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassReader.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassReader.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassReader.java
index 1e38c18..4801b61 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassReader.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassReader.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,15 +29,15 @@
*/
package org.apache.tapestry5.internal.plastic.asm;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
/**
* A Java class parser to make a {@link ClassVisitor} visit an existing class.
* This class parses a byte array conforming to the Java class file format and
* calls the appropriate visit methods of a given class visitor for each field,
* method and bytecode instruction encountered.
- *
+ *
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
@@ -47,27 +47,27 @@ public class ClassReader {
* True to enable signatures support.
*/
static final boolean SIGNATURES = true;
-
+
/**
* True to enable annotations support.
*/
static final boolean ANNOTATIONS = true;
-
+
/**
* True to enable stack map frames support.
*/
static final boolean FRAMES = true;
-
+
/**
* True to enable bytecode writing support.
*/
static final boolean WRITER = true;
-
+
/**
* True to enable JSR_W and GOTO_W support.
*/
static final boolean RESIZE = true;
-
+
/**
* Flag to skip method code. If this class is set <code>CODE</code>
* attribute won't be visited. This can be used, for example, to retrieve
@@ -146,7 +146,7 @@ public class ClassReader {
/**
* Constructs a new {@link ClassReader} object.
- *
+ *
* @param b the bytecode of the class to be read.
*/
public ClassReader(final byte[] b) {
@@ -155,13 +155,17 @@ public class ClassReader {
/**
* Constructs a new {@link ClassReader} object.
- *
+ *
* @param b the bytecode of the class to be read.
* @param off the start offset of the class data.
* @param len the length of the class data.
*/
public ClassReader(final byte[] b, final int off, final int len) {
this.b = b;
+ // checks the class version
+ if (readShort(6) > Opcodes.V1_7) {
+ throw new IllegalArgumentException();
+ }
// parses the constant pool
items = new int[readUnsignedShort(off + 8)];
int n = items.length;
@@ -178,6 +182,7 @@ public class ClassReader {
case ClassWriter.INT:
case ClassWriter.FLOAT:
case ClassWriter.NAME_TYPE:
+ case ClassWriter.INDY:
size = 5;
break;
case ClassWriter.LONG:
@@ -191,8 +196,12 @@ public class ClassReader {
max = size;
}
break;
+ case ClassWriter.HANDLE:
+ size = 4;
+ break;
// case ClassWriter.CLASS:
// case ClassWriter.STR:
+ // case ClassWriter.MTYPE
default:
size = 3;
break;
@@ -208,9 +217,9 @@ public class ClassReader {
* Returns the class's access flags (see {@link Opcodes}). This value may
* not reflect Deprecated and Synthetic flags when bytecode is before 1.5
* and those flags are represented by attributes.
- *
+ *
* @return the class access flags
- *
+ *
* @see ClassVisitor#visit(int, int, String, String, String, String[])
*/
public int getAccess() {
@@ -220,9 +229,9 @@ public class ClassReader {
/**
* Returns the internal name of the class (see
* {@link Type#getInternalName() getInternalName}).
- *
+ *
* @return the internal class name
- *
+ *
* @see ClassVisitor#visit(int, int, String, String, String, String[])
*/
public String getClassName() {
@@ -233,10 +242,10 @@ public class ClassReader {
* Returns the internal of name of the super class (see
* {@link Type#getInternalName() getInternalName}). For interfaces, the
* super class is {@link Object}.
- *
+ *
* @return the internal name of super class, or <tt>null</tt> for
* {@link Object} class.
- *
+ *
* @see ClassVisitor#visit(int, int, String, String, String, String[])
*/
public String getSuperName() {
@@ -247,10 +256,10 @@ public class ClassReader {
/**
* Returns the internal names of the class's interfaces (see
* {@link Type#getInternalName() getInternalName}).
- *
+ *
* @return the array of internal names for all implemented interfaces or
* <tt>null</tt>.
- *
+ *
* @see ClassVisitor#visit(int, int, String, String, String, String[])
*/
public String[] getInterfaces() {
@@ -270,7 +279,7 @@ public class ClassReader {
/**
* Copies the constant pool data into the given {@link ClassWriter}. Should
* be called before the {@link #accept(ClassVisitor,int)} method.
- *
+ *
* @param classWriter the {@link ClassWriter} to copy constant pool into.
*/
void copyPool(final ClassWriter classWriter) {
@@ -330,8 +339,32 @@ public class ClassReader {
}
break;
+ case ClassWriter.HANDLE: {
+ int fieldOrMethodRef = items[readUnsignedShort(index + 1)];
+ nameType = items[readUnsignedShort(fieldOrMethodRef + 2)];
+ item.set(ClassWriter.HANDLE_BASE + readByte(index),
+ readClass(fieldOrMethodRef, buf),
+ readUTF8(nameType, buf),
+ readUTF8(nameType + 2, buf));
+
+ }
+ break;
+
+
+ case ClassWriter.INDY:
+ if (classWriter.bootstrapMethods == null) {
+ copyBootstrapMethods(classWriter, items2, buf);
+ }
+ nameType = items[readUnsignedShort(index + 2)];
+ item.set(readUTF8(nameType, buf),
+ readUTF8(nameType + 2, buf),
+ readUnsignedShort(index));
+ break;
+
+
// case ClassWriter.STR:
// case ClassWriter.CLASS:
+ // case ClassWriter.MTYPE
default:
item.set(tag, readUTF8(index, buf), null, null);
break;
@@ -349,60 +382,135 @@ public class ClassReader {
classWriter.index = ll;
}
+ private void copyBootstrapMethods(ClassWriter classWriter, Item[] items2, char[] buf) {
+ int i, j, k, u, v;
+
+ // skip class header
+ v = header;
+ v += 8 + (readUnsignedShort(v + 6) << 1);
+
+ // skips fields and methods
+ i = readUnsignedShort(v);
+ v += 2;
+ for (; i > 0; --i) {
+ j = readUnsignedShort(v + 6);
+ v += 8;
+ for (; j > 0; --j) {
+ v += 6 + readInt(v + 2);
+ }
+ }
+ i = readUnsignedShort(v);
+ v += 2;
+ for (; i > 0; --i) {
+ j = readUnsignedShort(v + 6);
+ v += 8;
+ for (; j > 0; --j) {
+ v += 6 + readInt(v + 2);
+ }
+ }
+
+ // read class attributes
+ i = readUnsignedShort(v);
+ v += 2;
+ for (; i > 0; --i) {
+ String attrName = readUTF8(v, buf);
+ int size = readInt(v + 2);
+ if ("BootstrapMethods".equals(attrName)) {
+ int boostrapMethodCount = readUnsignedShort(v + 6);
+ int x = v + 8;
+ for (j = 0; j < boostrapMethodCount; j++) {
+ int hashCode = readConst(readUnsignedShort(x), buf).hashCode();
+ k = readUnsignedShort(x + 2);
+ u = x + 4;
+ for(; k > 0; --k) {
+ hashCode ^= readConst(readUnsignedShort(u), buf).hashCode();
+ u += 2;
+ }
+ Item item = new Item(j);
+ item.set(x - v - 8, hashCode & 0x7FFFFFFF);
+
+ int index2 = item.hashCode % items2.length;
+ item.next = items2[index2];
+ items2[index2] = item;
+
+ x = u;
+ }
+
+ classWriter.bootstrapMethodsCount = boostrapMethodCount;
+ ByteVector bootstrapMethods = new ByteVector(size + 62);
+ bootstrapMethods.putByteArray(b, v + 8, size - 2);
+ classWriter.bootstrapMethods = bootstrapMethods;
+ return;
+ }
+ v += 6 + size;
+ }
+
+ // we are in trouble !!!
+ }
+
/**
* Constructs a new {@link ClassReader} object.
- *
+ *
* @param is an input stream from which to read the class.
* @throws IOException if a problem occurs during reading.
*/
public ClassReader(final InputStream is) throws IOException {
- this(readClass(is));
+ this(readClass(is, false));
}
/**
* Constructs a new {@link ClassReader} object.
- *
- * @param name the fully qualified name of the class to be read.
+ *
+ * @param name the binary qualified name of the class to be read.
* @throws IOException if an exception occurs during reading.
*/
public ClassReader(final String name) throws IOException {
- this(ClassLoader.getSystemResourceAsStream(name.replace('.', '/')
- + ".class"));
+ this(readClass(ClassLoader.getSystemResourceAsStream(name.replace('.', '/')
+ + ".class"), true));
}
/**
* Reads the bytecode of a class.
- *
+ *
* @param is an input stream from which to read the class.
+ * @param close true to close the input stream after reading.
* @return the bytecode read from the given input stream.
* @throws IOException if a problem occurs during reading.
*/
- private static byte[] readClass(final InputStream is) throws IOException {
+ private static byte[] readClass(final InputStream is, boolean close)
+ throws IOException
+ {
if (is == null) {
throw new IOException("Class not found");
}
- byte[] b = new byte[is.available()];
- int len = 0;
- while (true) {
- int n = is.read(b, len, b.length - len);
- if (n == -1) {
- if (len < b.length) {
- byte[] c = new byte[len];
+ try {
+ byte[] b = new byte[is.available()];
+ int len = 0;
+ while (true) {
+ int n = is.read(b, len, b.length - len);
+ if (n == -1) {
+ if (len < b.length) {
+ byte[] c = new byte[len];
+ System.arraycopy(b, 0, c, 0, len);
+ b = c;
+ }
+ return b;
+ }
+ len += n;
+ if (len == b.length) {
+ int last = is.read();
+ if (last < 0) {
+ return b;
+ }
+ byte[] c = new byte[b.length + 1000];
System.arraycopy(b, 0, c, 0, len);
+ c[len++] = (byte) last;
b = c;
}
- return b;
}
- len += n;
- if (len == b.length) {
- int last = is.read();
- if (last < 0) {
- return b;
- }
- byte[] c = new byte[b.length + 1000];
- System.arraycopy(b, 0, c, 0, len);
- c[len++] = (byte) last;
- b = c;
+ } finally {
+ if (close) {
+ is.close();
}
}
}
@@ -415,7 +523,7 @@ public class ClassReader {
* Makes the given visitor visit the Java class of this {@link ClassReader}.
* This class is the one specified in the constructor (see
* {@link #ClassReader(byte[]) ClassReader}).
- *
+ *
* @param classVisitor the visitor that must visit this class.
* @param flags option flags that can be used to modify the default behavior
* of this class. See {@link #SKIP_DEBUG}, {@link #EXPAND_FRAMES},
@@ -429,7 +537,7 @@ public class ClassReader {
* Makes the given visitor visit the Java class of this {@link ClassReader}.
* This class is the one specified in the constructor (see
* {@link #ClassReader(byte[]) ClassReader}).
- *
+ *
* @param classVisitor the visitor that must visit this class.
* @param attrs prototypes of the attributes that must be parsed during the
* visit of the class. Any attribute whose type is not equal to the
@@ -508,6 +616,7 @@ public class ClassReader {
String enclosingOwner = null;
String enclosingName = null;
String enclosingDesc = null;
+ int[] bootstrapMethods = null; // start indexed of the bsms
i = readUnsignedShort(v);
v += 2;
@@ -539,6 +648,14 @@ public class ClassReader {
sourceDebug = readUTF(v + 6, len, new char[len]);
} else if (ANNOTATIONS && "RuntimeInvisibleAnnotations".equals(attrName)) {
ianns = v + 6;
+ } else if ("BootstrapMethods".equals(attrName)) {
+ int boostrapMethodCount = readUnsignedShort(v + 6);
+ bootstrapMethods = new int[boostrapMethodCount];
+ int x = v + 8;
+ for (j = 0; j < boostrapMethodCount; j++) {
+ bootstrapMethods[j] = x;
+ x += 2 + readUnsignedShort(x + 2) << 1;
+ }
} else {
attr = readAttribute(attrs,
attrName,
@@ -941,7 +1058,8 @@ public class ClassReader {
case ClassWriter.IINC_INSN:
v += 3;
break;
- case ClassWriter.ITFDYNMETH_INSN:
+ case ClassWriter.ITFMETH_INSN:
+ case ClassWriter.INDYMETH_INSN:
v += 5;
break;
// case MANA_INSN:
@@ -1148,11 +1266,11 @@ public class ClassReader {
* decoding each element of the stack map table, we look
* for 3 consecutive bytes that "look like" an UNINITIALIZED
* type (tag 8, offset within code bounds, NEW instruction
- * at this offset). We may find false positives (i.e. not
- * real UNINITIALIZED types), but this should be rare, and
- * the only consequence will be the creation of an unneeded
+ * at this offset). We may find false positives (i.e. not
+ * real UNINITIALIZED types), but this should be rare, and
+ * the only consequence will be the creation of an unneeded
* label. This is better than creating a label for each NEW
- * instruction, and faster than fully decoding the whole
+ * instruction, and faster than fully decoding the whole
* stack map table.
*/
for (j = stackMap; j < stackMap + stackMapSize - 2; ++j) {
@@ -1392,16 +1510,10 @@ public class ClassReader {
v += 3;
break;
case ClassWriter.FIELDORMETH_INSN:
- case ClassWriter.ITFDYNMETH_INSN:
+ case ClassWriter.ITFMETH_INSN: {
int cpIndex = items[readUnsignedShort(v + 1)];
- String iowner;
- // INVOKEDYNAMIC is receiverless
- if (opcode == Opcodes.INVOKEDYNAMIC) {
- iowner = Opcodes.INVOKEDYNAMIC_OWNER;
- } else {
- iowner = readClass(cpIndex, c);
- cpIndex = items[readUnsignedShort(cpIndex + 2)];
- }
+ String iowner = readClass(cpIndex, c);
+ cpIndex = items[readUnsignedShort(cpIndex + 2)];
String iname = readUTF8(cpIndex, c);
String idesc = readUTF8(cpIndex + 2, c);
if (opcode < Opcodes.INVOKEVIRTUAL) {
@@ -1409,12 +1521,35 @@ public class ClassReader {
} else {
mv.visitMethodInsn(opcode, iowner, iname, idesc);
}
- if (opcode == Opcodes.INVOKEINTERFACE || opcode == Opcodes.INVOKEDYNAMIC) {
+ if (opcode == Opcodes.INVOKEINTERFACE) {
v += 5;
} else {
v += 3;
}
break;
+ }
+ case ClassWriter.INDYMETH_INSN: {
+ int cpIndex = items[readUnsignedShort(v + 1)];
+ int bsmIndex = bootstrapMethods[readUnsignedShort(cpIndex)];
+ cpIndex = items[readUnsignedShort(cpIndex + 2)];
+ String iname = readUTF8(cpIndex, c);
+ String idesc = readUTF8(cpIndex + 2, c);
+
+ int mhIndex = readUnsignedShort(bsmIndex);
+ Handle bsm = (Handle) readConst(mhIndex, c);
+ int bsmArgCount = readUnsignedShort(bsmIndex + 2);
+ Object[] bsmArgs = new Object[bsmArgCount];
+ bsmIndex += 4;
+ for(int a = 0; a < bsmArgCount; a++) {
+ int argIndex = readUnsignedShort(bsmIndex);
+ bsmArgs[a] = readConst(argIndex, c);
+ bsmIndex += 2;
+ }
+ mv.visitInvokeDynamicInsn(iname, idesc, bsm, bsmArgs);
+
+ v += 5;
+ break;
+ }
case ClassWriter.TYPE_INSN:
mv.visitTypeInsn(opcode, readClass(v + 1, c));
v += 3;
@@ -1497,7 +1632,7 @@ public class ClassReader {
/**
* Reads parameter annotations and makes the given visitor visit them.
- *
+ *
* @param v start offset in {@link #b b} of the annotations to be read.
* @param desc the method descriptor.
* @param buf buffer to be used to call {@link #readUTF8 readUTF8},
@@ -1525,7 +1660,7 @@ public class ClassReader {
int synthetics = Type.getArgumentTypes(desc).length - n;
AnnotationVisitor av;
for (i = 0; i < synthetics; ++i) {
- // virtual annotation to detect synthetic parameters in MethodWriter
+ // virtual annotation to detect synthetic parameters in MethodWriter
av = mv.visitParameterAnnotation(i, "Ljava/lang/Synthetic;", false);
if (av != null) {
av.visitEnd();
@@ -1543,7 +1678,7 @@ public class ClassReader {
/**
* Reads the values of an annotation and makes the given visitor visit them.
- *
+ *
* @param v the start offset in {@link #b b} of the values to be read
* (including the unsigned short that gives the number of values).
* @param buf buffer to be used to call {@link #readUTF8 readUTF8},
@@ -1578,7 +1713,7 @@ public class ClassReader {
/**
* Reads a value of an annotation and makes the given visitor visit it.
- *
+ *
* @param v the start offset in {@link #b b} of the value to be read (<i>not
* including the value name constant pool index</i>).
* @param buf buffer to be used to call {@link #readUTF8 readUTF8},
@@ -1791,7 +1926,7 @@ public class ClassReader {
* Returns the label corresponding to the given offset. The default
* implementation of this method creates a label for the given offset if it
* has not been already created.
- *
+ *
* @param offset a bytecode offset in a method.
* @param labels the already created labels, indexed by their offset. If a
* label already exists for offset this method must not create a new
@@ -1807,7 +1942,7 @@ public class ClassReader {
/**
* Reads an attribute in {@link #b b}.
- *
+ *
* @param attrs prototypes of the attributes that must be parsed during the
* visit of the class. Any attribute whose type is not equal to the
* type of one the prototypes is ignored (i.e. an empty
@@ -1852,10 +1987,19 @@ public class ClassReader {
// ------------------------------------------------------------------------
/**
+ * Returns the number of constant pool items in {@link #b b}.
+ *
+ * @return the number of constant pool items in {@link #b b}.
+ */
+ public int getItemCount() {
+ return items.length;
+ }
+
+ /**
* Returns the start index of the constant pool item in {@link #b b}, plus
* one. <i>This method is intended for {@link Attribute} sub classes, and is
* normally not needed by class generators or adapters.</i>
- *
+ *
* @param item the index a constant pool item.
* @return the start index of the constant pool item in {@link #b b}, plus
* one.
@@ -1865,10 +2009,21 @@ public class ClassReader {
}
/**
+ * Returns the maximum length of the strings contained in the constant pool
+ * of the class.
+ *
+ * @return the maximum length of the strings contained in the constant pool
+ * of the class.
+ */
+ public int getMaxStringLength() {
+ return maxStringLength;
+ }
+
+ /**
* Reads a byte value in {@link #b b}. <i>This method is intended for
* {@link Attribute} sub classes, and is normally not needed by class
* generators or adapters.</i>
- *
+ *
* @param index the start index of the value to be read in {@link #b b}.
* @return the read value.
*/
@@ -1880,7 +2035,7 @@ public class ClassReader {
* Reads an unsigned short value in {@link #b b}. <i>This method is
* intended for {@link Attribute} sub classes, and is normally not needed by
* class generators or adapters.</i>
- *
+ *
* @param index the start index of the value to be read in {@link #b b}.
* @return the read value.
*/
@@ -1893,7 +2048,7 @@ public class ClassReader {
* Reads a signed short value in {@link #b b}. <i>This method is intended
* for {@link Attribute} sub classes, and is normally not needed by class
* generators or adapters.</i>
- *
+ *
* @param index the start index of the value to be read in {@link #b b}.
* @return the read value.
*/
@@ -1906,7 +2061,7 @@ public class ClassReader {
* Reads a signed int value in {@link #b b}. <i>This method is intended for
* {@link Attribute} sub classes, and is normally not needed by class
* generators or adapters.</i>
- *
+ *
* @param index the start index of the value to be read in {@link #b b}.
* @return the read value.
*/
@@ -1920,7 +2075,7 @@ public class ClassReader {
* Reads a signed long value in {@link #b b}. <i>This method is intended
* for {@link Attribute} sub classes, and is normally not needed by class
* generators or adapters.</i>
- *
+ *
* @param index the start index of the value to be read in {@link #b b}.
* @return the read value.
*/
@@ -1934,7 +2089,7 @@ public class ClassReader {
* Reads an UTF8 string constant pool item in {@link #b b}. <i>This method
* is intended for {@link Attribute} sub classes, and is normally not needed
* by class generators or adapters.</i>
- *
+ *
* @param index the start index of an unsigned short value in {@link #b b},
* whose value is the index of an UTF8 constant pool item.
* @param buf buffer to be used to read the item. This buffer must be
@@ -1953,7 +2108,7 @@ public class ClassReader {
/**
* Reads UTF8 string in {@link #b b}.
- *
+ *
* @param index start offset of the UTF8 string to be read.
* @param utfLen length of the UTF8 string to be read.
* @param buf buffer to be used to read the string. This buffer must be
@@ -1982,12 +2137,12 @@ public class ClassReader {
st = 2;
}
break;
-
- case 1: // byte 2 of 2-byte char or byte 3 of 3-byte char
+
+ case 1: // byte 2 of 2-byte char or byte 3 of 3-byte char
buf[strLen++] = (char) ((cc << 6) | (c & 0x3F));
st = 0;
break;
-
+
case 2: // byte 2 of 3-byte char
cc = (char) ((cc << 6) | (c & 0x3F));
st = 1;
@@ -1996,12 +2151,12 @@ public class ClassReader {
}
return new String(buf, 0, strLen);
}
-
+
/**
* Reads a class constant pool item in {@link #b b}. <i>This method is
* intended for {@link Attribute} sub classes, and is normally not needed by
* class generators or adapters.</i>
- *
+ *
* @param index the start index of an unsigned short value in {@link #b b},
* whose value is the index of a class constant pool item.
* @param buf buffer to be used to read the item. This buffer must be
@@ -2019,12 +2174,12 @@ public class ClassReader {
* Reads a numeric or string constant pool item in {@link #b b}. <i>This
* method is intended for {@link Attribute} sub classes, and is normally not
* needed by class generators or adapters.</i>
- *
+ *
* @param item the index of a constant pool item.
* @param buf buffer to be used to read the item. This buffer must be
* sufficiently large. It is not automatically resized.
- * @return the {@link Integer}, {@link Float}, {@link Long},
- * {@link Double}, {@link String} or {@link Type} corresponding to
+ * @return the {@link Integer}, {@link Float}, {@link Long}, {@link Double},
+ * {@link String}, {@link Type} or {@link Handle} corresponding to
* the given constant pool item.
*/
public Object readConst(final int item, final char[] buf) {
@@ -2040,9 +2195,22 @@ public class ClassReader {
return new Double(Double.longBitsToDouble(readLong(index)));
case ClassWriter.CLASS:
return Type.getObjectType(readUTF8(index, buf));
- // case ClassWriter.STR:
- default:
+ case ClassWriter.STR:
return readUTF8(index, buf);
+ case ClassWriter.MTYPE:
+ return Type.getMethodType(readUTF8(index, buf));
+
+ //case ClassWriter.HANDLE_BASE + [1..9]:
+ default: {
+ int tag = readByte(index);
+ int[] items = this.items;
+ int cpIndex = items[readUnsignedShort(index + 1)];
+ String owner = readClass(cpIndex, buf);
+ cpIndex = items[readUnsignedShort(cpIndex + 2)];
+ String name = readUTF8(cpIndex, buf);
+ String desc = readUTF8(cpIndex + 2, buf);
+ return new Handle(tag, owner, name, desc);
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassVisitor.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassVisitor.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassVisitor.java
index 5e95af6..dced23c 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassVisitor.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/ClassVisitor.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,19 +30,57 @@
package org.apache.tapestry5.internal.plastic.asm;
/**
- * A visitor to visit a Java class. The methods of this interface must be called
+ * A visitor to visit a Java class. The methods of this class must be called
* in the following order: <tt>visit</tt> [ <tt>visitSource</tt> ] [
* <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |
- * <tt>visitAttribute</tt> )* (<tt>visitInnerClass</tt> |
+ * <tt>visitAttribute</tt> )* ( <tt>visitInnerClass</tt> |
* <tt>visitField</tt> | <tt>visitMethod</tt> )* <tt>visitEnd</tt>.
- *
+ *
* @author Eric Bruneton
*/
-public interface ClassVisitor {
+public abstract class ClassVisitor {
+
+ /**
+ * The ASM API version implemented by this visitor. The value of this field
+ * must be one of {@link Opcodes#ASM4}.
+ */
+ protected final int api;
+
+ /**
+ * The class visitor to which this visitor must delegate method calls. May
+ * be null.
+ */
+ protected ClassVisitor cv;
+
+ /**
+ * Constructs a new {@link ClassVisitor}.
+ *
+ * @param api the ASM API version implemented by this visitor. Must be one
+ * of {@link Opcodes#ASM4}.
+ */
+ public ClassVisitor(final int api) {
+ this(api, null);
+ }
+
+ /**
+ * Constructs a new {@link ClassVisitor}.
+ *
+ * @param api the ASM API version implemented by this visitor. Must be one
+ * of {@link Opcodes#ASM4}.
+ * @param cv the class visitor to which this visitor must delegate method
+ * calls. May be null.
+ */
+ public ClassVisitor(final int api, final ClassVisitor cv) {
+ /*if (api != Opcodes.ASM4) {
+ throw new IllegalArgumentException();
+ }*/
+ this.api = api;
+ this.cv = cv;
+ }
/**
* Visits the header of the class.
- *
+ *
* @param version the class version.
* @param access the class's access flags (see {@link Opcodes}). This
* parameter also indicates if the class is deprecated.
@@ -59,29 +97,38 @@ public interface ClassVisitor {
* {@link Type#getInternalName() getInternalName}). May be
* <tt>null</tt>.
*/
- void visit(
+ public void visit(
int version,
int access,
String name,
String signature,
String superName,
- String[] interfaces);
+ String[] interfaces)
+ {
+ if (cv != null) {
+ cv.visit(version, access, name, signature, superName, interfaces);
+ }
+ }
/**
* Visits the source of the class.
- *
+ *
* @param source the name of the source file from which the class was
* compiled. May be <tt>null</tt>.
* @param debug additional debug information to compute the correspondance
* between source and compiled elements of the class. May be
* <tt>null</tt>.
*/
- void visitSource(String source, String debug);
+ public void visitSource(String source, String debug) {
+ if (cv != null) {
+ cv.visitSource(source, debug);
+ }
+ }
/**
* Visits the enclosing class of the class. This method must be called only
* if the class has an enclosing class.
- *
+ *
* @param owner internal name of the enclosing class of the class.
* @param name the name of the method that contains the class, or
* <tt>null</tt> if the class is not enclosed in a method of its
@@ -90,29 +137,42 @@ public interface ClassVisitor {
* <tt>null</tt> if the class is not enclosed in a method of its
* enclosing class.
*/
- void visitOuterClass(String owner, String name, String desc);
+ public void visitOuterClass(String owner, String name, String desc) {
+ if (cv != null) {
+ cv.visitOuterClass(owner, name, desc);
+ }
+ }
/**
* Visits an annotation of the class.
- *
+ *
* @param desc the class descriptor of the annotation class.
* @param visible <tt>true</tt> if the annotation is visible at runtime.
* @return a visitor to visit the annotation values, or <tt>null</tt> if
* this visitor is not interested in visiting this annotation.
*/
- AnnotationVisitor visitAnnotation(String desc, boolean visible);
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ if (cv != null) {
+ return cv.visitAnnotation(desc, visible);
+ }
+ return null;
+ }
/**
* Visits a non standard attribute of the class.
- *
+ *
* @param attr an attribute.
*/
- void visitAttribute(Attribute attr);
+ public void visitAttribute(Attribute attr) {
+ if (cv != null) {
+ cv.visitAttribute(attr);
+ }
+ }
/**
* Visits information about an inner class. This inner class is not
* necessarily a member of the class being visited.
- *
+ *
* @param name the internal name of an inner class (see
* {@link Type#getInternalName() getInternalName}).
* @param outerName the internal name of the class to which the inner class
@@ -124,15 +184,20 @@ public interface ClassVisitor {
* @param access the access flags of the inner class as originally declared
* in the enclosing class.
*/
- void visitInnerClass(
+ public void visitInnerClass(
String name,
String outerName,
String innerName,
- int access);
+ int access)
+ {
+ if (cv != null) {
+ cv.visitInnerClass(name, outerName, innerName, access);
+ }
+ }
/**
* Visits a field of the class.
- *
+ *
* @param access the field's access flags (see {@link Opcodes}). This
* parameter also indicates if the field is synthetic and/or
* deprecated.
@@ -153,18 +218,24 @@ public interface ClassVisitor {
* <tt>null</tt> if this class visitor is not interested in
* visiting these annotations and attributes.
*/
- FieldVisitor visitField(
+ public FieldVisitor visitField(
int access,
String name,
String desc,
String signature,
- Object value);
+ Object value)
+ {
+ if (cv != null) {
+ return cv.visitField(access, name, desc, signature, value);
+ }
+ return null;
+ }
/**
* Visits a method of the class. This method <i>must</i> return a new
* {@link MethodVisitor} instance (or <tt>null</tt>) each time it is
* called, i.e., it should not return a previously returned visitor.
- *
+ *
* @param access the method's access flags (see {@link Opcodes}). This
* parameter also indicates if the method is synthetic and/or
* deprecated.
@@ -180,17 +251,27 @@ public interface ClassVisitor {
* if this class visitor is not interested in visiting the code of
* this method.
*/
- MethodVisitor visitMethod(
+ public MethodVisitor visitMethod(
int access,
String name,
String desc,
String signature,
- String[] exceptions);
+ String[] exceptions)
+ {
+ if (cv != null) {
+ return cv.visitMethod(access, name, desc, signature, exceptions);
+ }
+ return null;
+ }
/**
* Visits the end of the class. This method, which is the last one to be
* called, is used to inform the visitor that all the fields and methods of
* the class have been visited.
*/
- void visitEnd();
+ public void visitEnd() {
+ if (cv != null) {
+ cv.visitEnd();
+ }
+ }
}