You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by th...@apache.org on 2018/11/29 00:34:13 UTC
[26/46] tapestry-5 git commit: TAP5-2588: upgrading from ASM 6 to 7
for Java 9+ support
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/Method.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/Method.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/Method.java
old mode 100644
new mode 100755
index f6f5857..70da1f5
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/Method.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/Method.java
@@ -1,282 +1,262 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
+// ASM: a very small and fast Java bytecode manipulation framework
+// Copyright (c) 2000-2011 INRIA, France Telecom
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. Neither the name of the copyright holders nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
package org.apache.tapestry5.internal.plastic.asm.commons;
import java.util.HashMap;
import java.util.Map;
-
import org.apache.tapestry5.internal.plastic.asm.Type;
/**
* A named method descriptor.
- *
+ *
* @author Juozas Baliuka
* @author Chris Nokleberg
* @author Eric Bruneton
*/
public class Method {
- /**
- * The method name.
- */
- private final String name;
+ /** The method name. */
+ private final String name;
- /**
- * The method descriptor.
- */
- private final String desc;
+ /** The method descriptor. */
+ private final String descriptor;
- /**
- * Maps primitive Java type names to their descriptors.
- */
- private static final Map<String, String> DESCRIPTORS;
+ /** The descriptors of the primitive Java types (plus void). */
+ private static final Map<String, String> PRIMITIVE_TYPE_DESCRIPTORS;
- static {
- DESCRIPTORS = new HashMap<String, String>();
- DESCRIPTORS.put("void", "V");
- DESCRIPTORS.put("byte", "B");
- DESCRIPTORS.put("char", "C");
- DESCRIPTORS.put("double", "D");
- DESCRIPTORS.put("float", "F");
- DESCRIPTORS.put("int", "I");
- DESCRIPTORS.put("long", "J");
- DESCRIPTORS.put("short", "S");
- DESCRIPTORS.put("boolean", "Z");
- }
+ static {
+ HashMap<String, String> descriptors = new HashMap<String, String>();
+ descriptors.put("void", "V");
+ descriptors.put("byte", "B");
+ descriptors.put("char", "C");
+ descriptors.put("double", "D");
+ descriptors.put("float", "F");
+ descriptors.put("int", "I");
+ descriptors.put("long", "J");
+ descriptors.put("short", "S");
+ descriptors.put("boolean", "Z");
+ PRIMITIVE_TYPE_DESCRIPTORS = descriptors;
+ }
- /**
- * Creates a new {@link Method}.
- *
- * @param name
- * the method's name.
- * @param desc
- * the method's descriptor.
- */
- public Method(final String name, final String desc) {
- this.name = name;
- this.desc = desc;
- }
+ /**
+ * Constructs a new {@link Method}.
+ *
+ * @param name the method's name.
+ * @param descriptor the method's descriptor.
+ */
+ public Method(final String name, final String descriptor) {
+ this.name = name;
+ this.descriptor = descriptor;
+ }
- /**
- * Creates a new {@link Method}.
- *
- * @param name
- * the method's name.
- * @param returnType
- * the method's return type.
- * @param argumentTypes
- * the method's argument types.
- */
- public Method(final String name, final Type returnType,
- final Type[] argumentTypes) {
- this(name, Type.getMethodDescriptor(returnType, argumentTypes));
- }
+ /**
+ * Constructs a new {@link Method}.
+ *
+ * @param name the method's name.
+ * @param returnType the method's return type.
+ * @param argumentTypes the method's argument types.
+ */
+ public Method(final String name, final Type returnType, final Type[] argumentTypes) {
+ this(name, Type.getMethodDescriptor(returnType, argumentTypes));
+ }
- /**
- * Creates a new {@link Method}.
- *
- * @param m
- * a java.lang.reflect method descriptor
- * @return a {@link Method} corresponding to the given Java method
- * declaration.
- */
- public static Method getMethod(java.lang.reflect.Method m) {
- return new Method(m.getName(), Type.getMethodDescriptor(m));
- }
+ /**
+ * Creates a new {@link Method}.
+ *
+ * @param method a java.lang.reflect method descriptor
+ * @return a {@link Method} corresponding to the given Java method declaration.
+ */
+ public static Method getMethod(final java.lang.reflect.Method method) {
+ return new Method(method.getName(), Type.getMethodDescriptor(method));
+ }
- /**
- * Creates a new {@link Method}.
- *
- * @param c
- * a java.lang.reflect constructor descriptor
- * @return a {@link Method} corresponding to the given Java constructor
- * declaration.
- */
- public static Method getMethod(java.lang.reflect.Constructor<?> c) {
- return new Method("<init>", Type.getConstructorDescriptor(c));
- }
+ /**
+ * Creates a new {@link Method}.
+ *
+ * @param constructor a java.lang.reflect constructor descriptor
+ * @return a {@link Method} corresponding to the given Java constructor declaration.
+ */
+ public static Method getMethod(final java.lang.reflect.Constructor<?> constructor) {
+ return new Method("<init>", Type.getConstructorDescriptor(constructor));
+ }
- /**
- * Returns a {@link Method} corresponding to the given Java method
- * declaration.
- *
- * @param method
- * a Java method declaration, without argument names, of the form
- * "returnType name (argumentType1, ... argumentTypeN)", where
- * the types are in plain Java (e.g. "int", "float",
- * "java.util.List", ...). Classes of the java.lang package can
- * be specified by their unqualified name; all other classes
- * names must be fully qualified.
- * @return a {@link Method} corresponding to the given Java method
- * declaration.
- * @throws IllegalArgumentException
- * if <code>method</code> could not get parsed.
- */
- public static Method getMethod(final String method)
- throws IllegalArgumentException {
- return getMethod(method, false);
- }
+ /**
+ * Returns a {@link Method} corresponding to the given Java method declaration.
+ *
+ * @param method a Java method declaration, without argument names, of the form "returnType name
+ * (argumentType1, ... argumentTypeN)", where the types are in plain Java (e.g. "int",
+ * "float", "java.util.List", ...). Classes of the java.lang package can be specified by their
+ * unqualified name; all other classes names must be fully qualified.
+ * @return a {@link Method} corresponding to the given Java method declaration.
+ * @throws IllegalArgumentException if <code>method</code> could not get parsed.
+ */
+ public static Method getMethod(final String method) {
+ return getMethod(method, false);
+ }
- /**
- * Returns a {@link Method} corresponding to the given Java method
- * declaration.
- *
- * @param method
- * a Java method declaration, without argument names, of the form
- * "returnType name (argumentType1, ... argumentTypeN)", where
- * the types are in plain Java (e.g. "int", "float",
- * "java.util.List", ...). Classes of the java.lang package may
- * be specified by their unqualified name, depending on the
- * defaultPackage argument; all other classes names must be fully
- * qualified.
- * @param defaultPackage
- * true if unqualified class names belong to the default package,
- * or false if they correspond to java.lang classes. For instance
- * "Object" means "Object" if this option is true, or
- * "java.lang.Object" otherwise.
- * @return a {@link Method} corresponding to the given Java method
- * declaration.
- * @throws IllegalArgumentException
- * if <code>method</code> could not get parsed.
- */
- public static Method getMethod(final String method,
- final boolean defaultPackage) throws IllegalArgumentException {
- int space = method.indexOf(' ');
- int start = method.indexOf('(', space) + 1;
- int end = method.indexOf(')', start);
- if (space == -1 || start == -1 || end == -1) {
- throw new IllegalArgumentException();
- }
- String returnType = method.substring(0, space);
- String methodName = method.substring(space + 1, start - 1).trim();
- StringBuilder sb = new StringBuilder();
- sb.append('(');
- int p;
- do {
- String s;
- p = method.indexOf(',', start);
- if (p == -1) {
- s = map(method.substring(start, end).trim(), defaultPackage);
- } else {
- s = map(method.substring(start, p).trim(), defaultPackage);
- start = p + 1;
- }
- sb.append(s);
- } while (p != -1);
- sb.append(')');
- sb.append(map(returnType, defaultPackage));
- return new Method(methodName, sb.toString());
+ /**
+ * Returns a {@link Method} corresponding to the given Java method declaration.
+ *
+ * @param method a Java method declaration, without argument names, of the form "returnType name
+ * (argumentType1, ... argumentTypeN)", where the types are in plain Java (e.g. "int",
+ * "float", "java.util.List", ...). Classes of the java.lang package may be specified by their
+ * unqualified name, depending on the defaultPackage argument; all other classes names must be
+ * fully qualified.
+ * @param defaultPackage true if unqualified class names belong to the default package, or false
+ * if they correspond to java.lang classes. For instance "Object" means "Object" if this
+ * option is true, or "java.lang.Object" otherwise.
+ * @return a {@link Method} corresponding to the given Java method declaration.
+ * @throws IllegalArgumentException if <code>method</code> could not get parsed.
+ */
+ public static Method getMethod(final String method, final boolean defaultPackage) {
+ final int spaceIndex = method.indexOf(' ');
+ int currentArgumentStartIndex = method.indexOf('(', spaceIndex) + 1;
+ final int endIndex = method.indexOf(')', currentArgumentStartIndex);
+ if (spaceIndex == -1 || currentArgumentStartIndex == 0 || endIndex == -1) {
+ throw new IllegalArgumentException();
}
+ final String returnType = method.substring(0, spaceIndex);
+ final String methodName =
+ method.substring(spaceIndex + 1, currentArgumentStartIndex - 1).trim();
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append('(');
+ int currentArgumentEndIndex;
+ do {
+ String argumentDescriptor;
+ currentArgumentEndIndex = method.indexOf(',', currentArgumentStartIndex);
+ if (currentArgumentEndIndex == -1) {
+ argumentDescriptor =
+ getDescriptorInternal(
+ method.substring(currentArgumentStartIndex, endIndex).trim(), defaultPackage);
+ } else {
+ argumentDescriptor =
+ getDescriptorInternal(
+ method.substring(currentArgumentStartIndex, currentArgumentEndIndex).trim(),
+ defaultPackage);
+ currentArgumentStartIndex = currentArgumentEndIndex + 1;
+ }
+ stringBuilder.append(argumentDescriptor);
+ } while (currentArgumentEndIndex != -1);
+ stringBuilder.append(')').append(getDescriptorInternal(returnType, defaultPackage));
+ return new Method(methodName, stringBuilder.toString());
+ }
- private static String map(final String type, final boolean defaultPackage) {
- if ("".equals(type)) {
- return type;
- }
+ /**
+ * Returns the descriptor corresponding to the given type name.
+ *
+ * @param type a Java type name.
+ * @param defaultPackage true if unqualified class names belong to the default package, or false
+ * if they correspond to java.lang classes. For instance "Object" means "Object" if this
+ * option is true, or "java.lang.Object" otherwise.
+ * @return the descriptor corresponding to the given type name.
+ */
+ private static String getDescriptorInternal(final String type, final boolean defaultPackage) {
+ if ("".equals(type)) {
+ return type;
+ }
- StringBuilder sb = new StringBuilder();
- int index = 0;
- while ((index = type.indexOf("[]", index) + 1) > 0) {
- sb.append('[');
- }
+ StringBuilder stringBuilder = new StringBuilder();
+ int arrayBracketsIndex = 0;
+ while ((arrayBracketsIndex = type.indexOf("[]", arrayBracketsIndex) + 1) > 0) {
+ stringBuilder.append('[');
+ }
- String t = type.substring(0, type.length() - sb.length() * 2);
- String desc = DESCRIPTORS.get(t);
- if (desc != null) {
- sb.append(desc);
- } else {
- sb.append('L');
- if (t.indexOf('.') < 0) {
- if (!defaultPackage) {
- sb.append("java/lang/");
- }
- sb.append(t);
- } else {
- sb.append(t.replace('.', '/'));
- }
- sb.append(';');
+ String elementType = type.substring(0, type.length() - stringBuilder.length() * 2);
+ String descriptor = PRIMITIVE_TYPE_DESCRIPTORS.get(elementType);
+ if (descriptor != null) {
+ stringBuilder.append(descriptor);
+ } else {
+ stringBuilder.append('L');
+ if (elementType.indexOf('.') < 0) {
+ if (!defaultPackage) {
+ stringBuilder.append("java/lang/");
}
- return sb.toString();
+ stringBuilder.append(elementType);
+ } else {
+ stringBuilder.append(elementType.replace('.', '/'));
+ }
+ stringBuilder.append(';');
}
+ return stringBuilder.toString();
+ }
- /**
- * Returns the name of the method described by this object.
- *
- * @return the name of the method described by this object.
- */
- public String getName() {
- return name;
- }
+ /**
+ * Returns the name of the method described by this object.
+ *
+ * @return the name of the method described by this object.
+ */
+ public String getName() {
+ return name;
+ }
- /**
- * Returns the descriptor of the method described by this object.
- *
- * @return the descriptor of the method described by this object.
- */
- public String getDescriptor() {
- return desc;
- }
+ /**
+ * Returns the descriptor of the method described by this object.
+ *
+ * @return the descriptor of the method described by this object.
+ */
+ public String getDescriptor() {
+ return descriptor;
+ }
- /**
- * Returns the return type of the method described by this object.
- *
- * @return the return type of the method described by this object.
- */
- public Type getReturnType() {
- return Type.getReturnType(desc);
- }
+ /**
+ * Returns the return type of the method described by this object.
+ *
+ * @return the return type of the method described by this object.
+ */
+ public Type getReturnType() {
+ return Type.getReturnType(descriptor);
+ }
- /**
- * Returns the argument types of the method described by this object.
- *
- * @return the argument types of the method described by this object.
- */
- public Type[] getArgumentTypes() {
- return Type.getArgumentTypes(desc);
- }
+ /**
+ * Returns the argument types of the method described by this object.
+ *
+ * @return the argument types of the method described by this object.
+ */
+ public Type[] getArgumentTypes() {
+ return Type.getArgumentTypes(descriptor);
+ }
- @Override
- public String toString() {
- return name + desc;
- }
+ @Override
+ public String toString() {
+ return name + descriptor;
+ }
- @Override
- public boolean equals(final Object o) {
- if (!(o instanceof Method)) {
- return false;
- }
- Method other = (Method) o;
- return name.equals(other.name) && desc.equals(other.desc);
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof Method)) {
+ return false;
}
+ Method otherMethod = (Method) other;
+ return name.equals(otherMethod.name) && descriptor.equals(otherMethod.descriptor);
+ }
- @Override
- public int hashCode() {
- return name.hashCode() ^ desc.hashCode();
- }
-}
\ No newline at end of file
+ @Override
+ public int hashCode() {
+ return name.hashCode() ^ descriptor.hashCode();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/MethodRemapper.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/MethodRemapper.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/MethodRemapper.java
old mode 100644
new mode 100755
index 03e56be..20cfa5a
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/MethodRemapper.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/MethodRemapper.java
@@ -1,32 +1,30 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
+// ASM: a very small and fast Java bytecode manipulation framework
+// Copyright (c) 2000-2011 INRIA, France Telecom
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. Neither the name of the copyright holders nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
package org.apache.tapestry5.internal.plastic.asm.commons;
@@ -38,188 +36,258 @@ import org.apache.tapestry5.internal.plastic.asm.Opcodes;
import org.apache.tapestry5.internal.plastic.asm.TypePath;
/**
- * A {@link LocalVariablesSorter} for type mapping.
- *
+ * A {@link MethodVisitor} that remaps types with a {@link Remapper}.
+ *
* @author Eugene Kuleshov
*/
public class MethodRemapper extends MethodVisitor {
- protected final Remapper remapper;
+ /** The remapper used to remap the types in the visited field. */
+ protected final Remapper remapper;
- public MethodRemapper(final MethodVisitor mv, final Remapper remapper) {
- this(Opcodes.ASM6, mv, remapper);
- }
+ /**
+ * Constructs a new {@link MethodRemapper}. <i>Subclasses must not use this constructor</i>.
+ * Instead, they must use the {@link #MethodRemapper(int,MethodVisitor,Remapper)} version.
+ *
+ * @param methodVisitor the method visitor this remapper must deleted to.
+ * @param remapper the remapper to use to remap the types in the visited method.
+ */
+ public MethodRemapper(final MethodVisitor methodVisitor, final Remapper remapper) {
+ this(Opcodes.ASM7, methodVisitor, remapper);
+ }
- protected MethodRemapper(final int api, final MethodVisitor mv,
- final Remapper remapper) {
- super(api, mv);
- this.remapper = remapper;
- }
+ /**
+ * Constructs a new {@link MethodRemapper}.
+ *
+ * @param api the ASM API version supported by this remapper. Must be one of {@link
+ * org.apache.tapestry5.internal.plastic.asm.Opcodes#ASM4}, {@link org.apache.tapestry5.internal.plastic.asm.Opcodes#ASM5} or {@link
+ * org.apache.tapestry5.internal.plastic.asm.Opcodes#ASM6}.
+ * @param methodVisitor the method visitor this remapper must deleted to.
+ * @param remapper the remapper to use to remap the types in the visited method.
+ */
+ protected MethodRemapper(
+ final int api, final MethodVisitor methodVisitor, final Remapper remapper) {
+ super(api, methodVisitor);
+ this.remapper = remapper;
+ }
- @Override
- public AnnotationVisitor visitAnnotationDefault() {
- AnnotationVisitor av = super.visitAnnotationDefault();
- return av == null ? av : new AnnotationRemapper(av, remapper);
- }
+ @Override
+ public AnnotationVisitor visitAnnotationDefault() {
+ AnnotationVisitor annotationVisitor = super.visitAnnotationDefault();
+ return annotationVisitor == null
+ ? annotationVisitor
+ : new AnnotationRemapper(api, annotationVisitor, remapper);
+ }
- @Override
- public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
- AnnotationVisitor av = super.visitAnnotation(remapper.mapDesc(desc),
- visible);
- return av == null ? av : new AnnotationRemapper(av, remapper);
- }
+ @Override
+ public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
+ AnnotationVisitor annotationVisitor =
+ super.visitAnnotation(remapper.mapDesc(descriptor), visible);
+ return annotationVisitor == null
+ ? annotationVisitor
+ : new AnnotationRemapper(api, annotationVisitor, remapper);
+ }
- @Override
- public AnnotationVisitor visitTypeAnnotation(int typeRef,
- TypePath typePath, String desc, boolean visible) {
- AnnotationVisitor av = super.visitTypeAnnotation(typeRef, typePath,
- remapper.mapDesc(desc), visible);
- return av == null ? av : new AnnotationRemapper(av, remapper);
- }
+ @Override
+ public AnnotationVisitor visitTypeAnnotation(
+ final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
+ AnnotationVisitor annotationVisitor =
+ super.visitTypeAnnotation(typeRef, typePath, remapper.mapDesc(descriptor), visible);
+ return annotationVisitor == null
+ ? annotationVisitor
+ : new AnnotationRemapper(api, annotationVisitor, remapper);
+ }
- @Override
- public AnnotationVisitor visitParameterAnnotation(int parameter,
- String desc, boolean visible) {
- AnnotationVisitor av = super.visitParameterAnnotation(parameter,
- remapper.mapDesc(desc), visible);
- return av == null ? av : new AnnotationRemapper(av, remapper);
- }
+ @Override
+ public AnnotationVisitor visitParameterAnnotation(
+ final int parameter, final String descriptor, final boolean visible) {
+ AnnotationVisitor annotationVisitor =
+ super.visitParameterAnnotation(parameter, remapper.mapDesc(descriptor), visible);
+ return annotationVisitor == null
+ ? annotationVisitor
+ : new AnnotationRemapper(api, annotationVisitor, remapper);
+ }
- @Override
- public void visitFrame(int type, int nLocal, Object[] local, int nStack,
- Object[] stack) {
- super.visitFrame(type, nLocal, remapEntries(nLocal, local), nStack,
- remapEntries(nStack, stack));
- }
+ @Override
+ public void visitFrame(
+ final int type,
+ final int numLocal,
+ final Object[] local,
+ final int numStack,
+ final Object[] stack) {
+ super.visitFrame(
+ type,
+ numLocal,
+ remapFrameTypes(numLocal, local),
+ numStack,
+ remapFrameTypes(numStack, stack));
+ }
- private Object[] remapEntries(int n, Object[] entries) {
- if (entries != null) {
- for (int i = 0; i < n; i++) {
- if (entries[i] instanceof String) {
- Object[] newEntries = new Object[n];
- if (i > 0) {
- System.arraycopy(entries, 0, newEntries, 0, i);
- }
- do {
- Object t = entries[i];
- newEntries[i++] = t instanceof String ? remapper
- .mapType((String) t) : t;
- } while (i < n);
- return newEntries;
- }
- }
+ private Object[] remapFrameTypes(final int numTypes, final Object[] frameTypes) {
+ if (frameTypes == null) {
+ return frameTypes;
+ }
+ Object[] remappedFrameTypes = null;
+ for (int i = 0; i < numTypes; ++i) {
+ if (frameTypes[i] instanceof String) {
+ if (remappedFrameTypes == null) {
+ remappedFrameTypes = new Object[numTypes];
+ System.arraycopy(frameTypes, 0, remappedFrameTypes, 0, numTypes);
}
- return entries;
+ remappedFrameTypes[i] = remapper.mapType((String) frameTypes[i]);
+ }
}
+ return remappedFrameTypes == null ? frameTypes : remappedFrameTypes;
+ }
- @Override
- public void visitFieldInsn(int opcode, String owner, String name,
- String desc) {
- super.visitFieldInsn(opcode, remapper.mapType(owner),
- remapper.mapFieldName(owner, name, desc),
- remapper.mapDesc(desc));
- }
+ @Override
+ public void visitFieldInsn(
+ final int opcode, final String owner, final String name, final String descriptor) {
+ super.visitFieldInsn(
+ opcode,
+ remapper.mapType(owner),
+ remapper.mapFieldName(owner, name, descriptor),
+ remapper.mapDesc(descriptor));
+ }
- @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);
+ /**
+ * Deprecated.
+ *
+ * @deprecated use {@link #visitMethodInsn(int, String, String, String, boolean)} instead.
+ */
+ @Deprecated
+ @Override
+ public void visitMethodInsn(
+ final int opcode, final String owner, final String name, final String descriptor) {
+ if (api >= Opcodes.ASM5) {
+ super.visitMethodInsn(opcode, owner, name, descriptor);
+ return;
}
+ doVisitMethodInsn(opcode, owner, name, descriptor, 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);
+ @Override
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String descriptor,
+ final boolean isInterface) {
+ if (api < Opcodes.ASM5) {
+ super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
+ return;
}
+ doVisitMethodInsn(opcode, owner, name, descriptor, isInterface);
+ }
- private void doVisitMethodInsn(int opcode, String owner, String name,
- String desc, boolean itf) {
- // Calling super.visitMethodInsn requires to call the correct version
- // depending on this.api (otherwise infinite loops can occur). To
- // simplify and to make it easier to automatically remove the backward
- // compatibility code, we inline the code of the overridden method here.
- // IMPORTANT: THIS ASSUMES THAT visitMethodInsn IS NOT OVERRIDDEN IN
- // LocalVariableSorter.
- if (mv != null) {
- mv.visitMethodInsn(opcode, remapper.mapType(owner),
- remapper.mapMethodName(owner, name, desc),
- remapper.mapMethodDesc(desc), itf);
- }
+ private void doVisitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String descriptor,
+ final boolean isInterface) {
+ // Calling super.visitMethodInsn requires to call the correct version depending on this.api
+ // (otherwise infinite loops can occur). To simplify and to make it easier to automatically
+ // remove the backward compatibility code, we inline the code of the overridden method here.
+ if (mv != null) {
+ mv.visitMethodInsn(
+ opcode,
+ remapper.mapType(owner),
+ remapper.mapMethodName(owner, name, descriptor),
+ remapper.mapMethodDesc(descriptor),
+ isInterface);
}
+ }
- @Override
- public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
- Object... bsmArgs) {
- for (int i = 0; i < bsmArgs.length; i++) {
- bsmArgs[i] = remapper.mapValue(bsmArgs[i]);
- }
- super.visitInvokeDynamicInsn(
- remapper.mapInvokeDynamicMethodName(name, desc),
- remapper.mapMethodDesc(desc), (Handle) remapper.mapValue(bsm),
- bsmArgs);
+ @Override
+ public void visitInvokeDynamicInsn(
+ final String name,
+ final String descriptor,
+ final Handle bootstrapMethodHandle,
+ final Object... bootstrapMethodArguments) {
+ Object[] remappedBootstrapMethodArguments = new Object[bootstrapMethodArguments.length];
+ for (int i = 0; i < bootstrapMethodArguments.length; ++i) {
+ remappedBootstrapMethodArguments[i] = remapper.mapValue(bootstrapMethodArguments[i]);
}
+ super.visitInvokeDynamicInsn(
+ remapper.mapInvokeDynamicMethodName(name, descriptor),
+ remapper.mapMethodDesc(descriptor),
+ (Handle) remapper.mapValue(bootstrapMethodHandle),
+ remappedBootstrapMethodArguments);
+ }
- @Override
- public void visitTypeInsn(int opcode, String type) {
- super.visitTypeInsn(opcode, remapper.mapType(type));
- }
+ @Override
+ public void visitTypeInsn(final int opcode, final String type) {
+ super.visitTypeInsn(opcode, remapper.mapType(type));
+ }
- @Override
- public void visitLdcInsn(Object cst) {
- super.visitLdcInsn(remapper.mapValue(cst));
- }
+ @Override
+ public void visitLdcInsn(final Object value) {
+ super.visitLdcInsn(remapper.mapValue(value));
+ }
- @Override
- public void visitMultiANewArrayInsn(String desc, int dims) {
- super.visitMultiANewArrayInsn(remapper.mapDesc(desc), dims);
- }
+ @Override
+ public void visitMultiANewArrayInsn(final String descriptor, final int numDimensions) {
+ super.visitMultiANewArrayInsn(remapper.mapDesc(descriptor), numDimensions);
+ }
- @Override
- public AnnotationVisitor visitInsnAnnotation(int typeRef,
- TypePath typePath, String desc, boolean visible) {
- AnnotationVisitor av = super.visitInsnAnnotation(typeRef, typePath,
- remapper.mapDesc(desc), visible);
- return av == null ? av : new AnnotationRemapper(av, remapper);
- }
+ @Override
+ public AnnotationVisitor visitInsnAnnotation(
+ final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
+ AnnotationVisitor annotationVisitor =
+ super.visitInsnAnnotation(typeRef, typePath, remapper.mapDesc(descriptor), visible);
+ return annotationVisitor == null
+ ? annotationVisitor
+ : new AnnotationRemapper(api, annotationVisitor, remapper);
+ }
- @Override
- public void visitTryCatchBlock(Label start, Label end, Label handler,
- String type) {
- super.visitTryCatchBlock(start, end, handler, type == null ? null
- : remapper.mapType(type));
- }
+ @Override
+ public void visitTryCatchBlock(
+ final Label start, final Label end, final Label handler, final String type) {
+ super.visitTryCatchBlock(start, end, handler, type == null ? null : remapper.mapType(type));
+ }
- @Override
- public AnnotationVisitor visitTryCatchAnnotation(int typeRef,
- TypePath typePath, String desc, boolean visible) {
- AnnotationVisitor av = super.visitTryCatchAnnotation(typeRef, typePath,
- remapper.mapDesc(desc), visible);
- return av == null ? av : new AnnotationRemapper(av, remapper);
- }
+ @Override
+ public AnnotationVisitor visitTryCatchAnnotation(
+ final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
+ AnnotationVisitor annotationVisitor =
+ super.visitTryCatchAnnotation(typeRef, typePath, remapper.mapDesc(descriptor), visible);
+ return annotationVisitor == null
+ ? annotationVisitor
+ : new AnnotationRemapper(api, annotationVisitor, remapper);
+ }
- @Override
- public void visitLocalVariable(String name, String desc, String signature,
- Label start, Label end, int index) {
- super.visitLocalVariable(name, remapper.mapDesc(desc),
- remapper.mapSignature(signature, true), start, end, index);
- }
+ @Override
+ public void visitLocalVariable(
+ final String name,
+ final String descriptor,
+ final String signature,
+ final Label start,
+ final Label end,
+ final int index) {
+ super.visitLocalVariable(
+ name,
+ remapper.mapDesc(descriptor),
+ remapper.mapSignature(signature, true),
+ start,
+ end,
+ index);
+ }
- @Override
- public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
- TypePath typePath, Label[] start, Label[] end, int[] index,
- String desc, boolean visible) {
- AnnotationVisitor av = super.visitLocalVariableAnnotation(typeRef,
- typePath, start, end, index, remapper.mapDesc(desc), visible);
- return av == null ? av : new AnnotationRemapper(av, remapper);
- }
+ @Override
+ public AnnotationVisitor visitLocalVariableAnnotation(
+ final int typeRef,
+ final TypePath typePath,
+ final Label[] start,
+ final Label[] end,
+ final int[] index,
+ final String descriptor,
+ final boolean visible) {
+ AnnotationVisitor annotationVisitor =
+ super.visitLocalVariableAnnotation(
+ typeRef, typePath, start, end, index, remapper.mapDesc(descriptor), visible);
+ return annotationVisitor == null
+ ? annotationVisitor
+ : new AnnotationRemapper(api, annotationVisitor, remapper);
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleHashesAttribute.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleHashesAttribute.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleHashesAttribute.java
old mode 100644
new mode 100755
index 5a46fa4..62c54c6
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleHashesAttribute.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleHashesAttribute.java
@@ -1,38 +1,35 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
+// ASM: a very small and fast Java bytecode manipulation framework
+// Copyright (c) 2000-2011 INRIA, France Telecom
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. Neither the name of the copyright holders nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
package org.apache.tapestry5.internal.plastic.asm.commons;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.tapestry5.internal.plastic.asm.Attribute;
import org.apache.tapestry5.internal.plastic.asm.ByteVector;
import org.apache.tapestry5.internal.plastic.asm.ClassReader;
@@ -40,87 +37,103 @@ import org.apache.tapestry5.internal.plastic.asm.ClassWriter;
import org.apache.tapestry5.internal.plastic.asm.Label;
/**
- * ModuleHashes attribute.
- * This attribute is specific to the OpenJDK and may change in the future.
- *
+ * A ModuleHashes attribute. This attribute is specific to the OpenJDK and may change in the future.
+ *
* @author Remi Forax
*/
public final class ModuleHashesAttribute extends Attribute {
- public String algorithm;
- public List<String> modules;
- public List<byte[]> hashes;
-
- /**
- * Creates an attribute with a hashing algorithm, a list of module names,
- * and a list of the same length of hashes.
- * @param algorithm the hashing algorithm name.
- * @param modules a list of module name
- * @param hashes a list of hash, one for each module name.
- */
- public ModuleHashesAttribute(final String algorithm,
- final List<String> modules, final List<byte[]> hashes) {
- super("ModuleHashes");
- this.algorithm = algorithm;
- this.modules = modules;
- this.hashes = hashes;
- }
-
- /**
- * Creates an empty attribute that can be used as prototype
- * to be passed as argument of the method
- * {@link ClassReader#accept(org.objectweb.asm.ClassVisitor, Attribute[], int)}.
- */
- public ModuleHashesAttribute() {
- this(null, null, null);
- }
-
- @Override
- protected Attribute read(ClassReader cr, int off, int len, char[] buf,
- int codeOff, Label[] labels) {
- String hashAlgorithm = cr.readUTF8(off, buf);
-
- int count = cr.readUnsignedShort(off + 2);
- ArrayList<String> modules = new ArrayList<String>(count);
- ArrayList<byte[]> hashes = new ArrayList<byte[]>(count);
- off += 4;
-
- for (int i = 0; i < count; i++) {
- String module = cr.readModule(off, buf);
- int hashLength = cr.readUnsignedShort(off + 2);
- off += 4;
- byte[] hash = new byte[hashLength];
- for (int j = 0; j < hashLength; j++) {
- hash[j] = (byte) (cr.readByte(off + j) & 0xff);
- }
- off += hashLength;
+ /** The name of the hashing algorithm. */
+ public String algorithm;
+
+ /** A list of module names. */
+ public List<String> modules;
+
+ /** The hash of the modules in {@link #modules}. The two lists must have the same size. */
+ public List<byte[]> hashes;
+
+ /**
+ * Constructs a new {@link ModuleHashesAttribute}.
+ *
+ * @param algorithm the name of the hashing algorithm.
+ * @param modules a list of module names.
+ * @param hashes the hash of the modules in 'modules'. The two lists must have the same size.
+ */
+ public ModuleHashesAttribute(
+ final String algorithm, final List<String> modules, final List<byte[]> hashes) {
+ super("ModuleHashes");
+ this.algorithm = algorithm;
+ this.modules = modules;
+ this.hashes = hashes;
+ }
+
+ /**
+ * Constructs an empty {@link ModuleHashesAttribute}. This object can be passed as a prototype to
+ * the {@link ClassReader#accept(org.apache.tapestry5.internal.plastic.asm.ClassVisitor, Attribute[], int)} method.
+ */
+ public ModuleHashesAttribute() {
+ this(null, null, null);
+ }
+
+ @Override
+ protected Attribute read(
+ final ClassReader classReader,
+ final int offset,
+ final int length,
+ final char[] charBuffer,
+ final int codeAttributeOffset,
+ final Label[] labels) {
+ int currentOffset = offset;
+
+ String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer);
+ currentOffset += 2;
+
+ int numModules = classReader.readUnsignedShort(currentOffset);
+ currentOffset += 2;
+
+ ArrayList<String> moduleList = new ArrayList<String>(numModules);
+ ArrayList<byte[]> hashList = new ArrayList<byte[]>(numModules);
+
+ for (int i = 0; i < numModules; ++i) {
+ String module = classReader.readModule(currentOffset, charBuffer);
+ currentOffset += 2;
+ moduleList.add(module);
- modules.add(module);
- hashes.add(hash);
- }
- return new ModuleHashesAttribute(hashAlgorithm, modules, hashes);
+ int hashLength = classReader.readUnsignedShort(currentOffset);
+ currentOffset += 2;
+ byte[] hash = new byte[hashLength];
+ for (int j = 0; j < hashLength; ++j) {
+ hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF);
+ currentOffset += 1;
+ }
+ hashList.add(hash);
}
-
- @Override
- protected ByteVector write(ClassWriter cw, byte[] code, int len,
- int maxStack, int maxLocals) {
- ByteVector v = new ByteVector();
- int index = cw.newUTF8(algorithm);
- v.putShort(index);
+ return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList);
+ }
- int count = (modules == null)? 0: modules.size();
- v.putShort(count);
-
- for(int i = 0; i < count; i++) {
- String module = modules.get(i);
- v.putShort(cw.newModule(module));
-
- byte[] hash = hashes.get(i);
- v.putShort(hash.length);
- for(byte b: hash) {
- v.putByte(b);
- }
- }
- return v;
+ @Override
+ protected ByteVector write(
+ final ClassWriter classWriter,
+ final byte[] code,
+ final int codeLength,
+ final int maxStack,
+ final int maxLocals) {
+ ByteVector byteVector = new ByteVector();
+ byteVector.putShort(classWriter.newUTF8(algorithm));
+ if (modules == null) {
+ byteVector.putShort(0);
+ } else {
+ int numModules = modules.size();
+ byteVector.putShort(numModules);
+ for (int i = 0; i < numModules; ++i) {
+ String module = modules.get(i);
+ byte[] hash = hashes.get(i);
+ byteVector
+ .putShort(classWriter.newModule(module))
+ .putShort(hash.length)
+ .putByteArray(hash, 0, hash.length);
+ }
}
+ return byteVector;
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleRemapper.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleRemapper.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleRemapper.java
old mode 100644
new mode 100755
index c3fd7a9..8d9eda4
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleRemapper.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleRemapper.java
@@ -1,32 +1,30 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
+// ASM: a very small and fast Java bytecode manipulation framework
+// Copyright (c) 2000-2011 INRIA, France Telecom
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. Neither the name of the copyright holders nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
package org.apache.tapestry5.internal.plastic.asm.commons;
@@ -34,73 +32,91 @@ import org.apache.tapestry5.internal.plastic.asm.ModuleVisitor;
import org.apache.tapestry5.internal.plastic.asm.Opcodes;
/**
- * A {@link ModuleVisitor} adapter for type remapping.
- *
+ * A {@link ModuleVisitor} that remaps types with a {@link Remapper}.
+ *
* @author Remi Forax
*/
public class ModuleRemapper extends ModuleVisitor {
- private final Remapper remapper;
- public ModuleRemapper(final ModuleVisitor mv, final Remapper remapper) {
- this(Opcodes.ASM6, mv, remapper);
- }
+ /** The remapper used to remap the types in the visited module. */
+ protected final Remapper remapper;
- protected ModuleRemapper(final int api, final ModuleVisitor mv,
- final Remapper remapper) {
- super(api, mv);
- this.remapper = remapper;
- }
+ /**
+ * Constructs a new {@link ModuleRemapper}. <i>Subclasses must not use this constructor</i>.
+ * Instead, they must use the {@link #ModuleRemapper(int,ModuleVisitor,Remapper)} version.
+ *
+ * @param moduleVisitor the module visitor this remapper must deleted to.
+ * @param remapper the remapper to use to remap the types in the visited module.
+ */
+ public ModuleRemapper(final ModuleVisitor moduleVisitor, final Remapper remapper) {
+ this(Opcodes.ASM7, moduleVisitor, remapper);
+ }
- @Override
- public void visitMainClass(String mainClass) {
- super.visitMainClass(remapper.mapType(mainClass));
- }
-
- @Override
- public void visitPackage(String packaze) {
- super.visitPackage(remapper.mapPackageName(packaze));
- }
-
- @Override
- public void visitRequire(String module, int access, String version) {
- super.visitRequire(remapper.mapModuleName(module), access, version);
- }
-
- @Override
- public void visitExport(String packaze, int access, String... modules) {
- String[] newModules = null;
- if (modules != null) {
- newModules = new String[modules.length];
- for (int i = 0 ; i < modules.length; i++) {
- newModules[i] = remapper.mapModuleName(modules[i]);
- }
- }
- super.visitExport(remapper.mapPackageName(packaze), access, newModules);
- }
-
- @Override
- public void visitOpen(String packaze, int access, String... modules) {
- String[] newModules = null;
- if (modules != null) {
- newModules = new String[modules.length];
- for (int i = 0 ; i < modules.length; i++) {
- newModules[i] = remapper.mapModuleName(modules[i]);
- }
- }
- super.visitOpen(remapper.mapPackageName(packaze), access, newModules);
+ /**
+ * Constructs a new {@link ModuleRemapper}.
+ *
+ * @param api the ASM API version supported by this remapper. Must be one of {@link
+ * org.apache.tapestry5.internal.plastic.asm.Opcodes#ASM4}, {@link org.apache.tapestry5.internal.plastic.asm.Opcodes#ASM5} or {@link
+ * org.apache.tapestry5.internal.plastic.asm.Opcodes#ASM6}.
+ * @param moduleVisitor the module visitor this remapper must deleted to.
+ * @param remapper the remapper to use to remap the types in the visited module.
+ */
+ protected ModuleRemapper(
+ final int api, final ModuleVisitor moduleVisitor, final Remapper remapper) {
+ super(api, moduleVisitor);
+ this.remapper = remapper;
+ }
+
+ @Override
+ public void visitMainClass(final String mainClass) {
+ super.visitMainClass(remapper.mapType(mainClass));
+ }
+
+ @Override
+ public void visitPackage(final String packaze) {
+ super.visitPackage(remapper.mapPackageName(packaze));
+ }
+
+ @Override
+ public void visitRequire(final String module, final int access, final String version) {
+ super.visitRequire(remapper.mapModuleName(module), access, version);
+ }
+
+ @Override
+ public void visitExport(final String packaze, final int access, final String... modules) {
+ String[] remappedModules = null;
+ if (modules != null) {
+ remappedModules = new String[modules.length];
+ for (int i = 0; i < modules.length; ++i) {
+ remappedModules[i] = remapper.mapModuleName(modules[i]);
+ }
}
-
- @Override
- public void visitUse(String service) {
- super.visitUse(remapper.mapType(service));
+ super.visitExport(remapper.mapPackageName(packaze), access, remappedModules);
+ }
+
+ @Override
+ public void visitOpen(final String packaze, final int access, final String... modules) {
+ String[] remappedModules = null;
+ if (modules != null) {
+ remappedModules = new String[modules.length];
+ for (int i = 0; i < modules.length; ++i) {
+ remappedModules[i] = remapper.mapModuleName(modules[i]);
+ }
}
-
- @Override
- public void visitProvide(String service, String... providers) {
- String[] newProviders = new String[providers.length];
- for (int i = 0 ; i < providers.length; i++) {
- newProviders[i] = remapper.mapType(providers[i]);
- }
- super.visitProvide(remapper.mapType(service), newProviders);
+ super.visitOpen(remapper.mapPackageName(packaze), access, remappedModules);
+ }
+
+ @Override
+ public void visitUse(final String service) {
+ super.visitUse(remapper.mapType(service));
+ }
+
+ @Override
+ public void visitProvide(final String service, final String... providers) {
+ String[] remappedProviders = new String[providers.length];
+ for (int i = 0; i < providers.length; ++i) {
+ remappedProviders[i] = remapper.mapType(providers[i]);
}
+ super.visitProvide(remapper.mapType(service), remappedProviders);
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleResolutionAttribute.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleResolutionAttribute.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleResolutionAttribute.java
old mode 100644
new mode 100755
index e2cf83c..27396dc
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleResolutionAttribute.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleResolutionAttribute.java
@@ -1,32 +1,30 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
+// ASM: a very small and fast Java bytecode manipulation framework
+// Copyright (c) 2000-2011 INRIA, France Telecom
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. Neither the name of the copyright holders nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
package org.apache.tapestry5.internal.plastic.asm.commons;
@@ -37,70 +35,79 @@ import org.apache.tapestry5.internal.plastic.asm.ClassWriter;
import org.apache.tapestry5.internal.plastic.asm.Label;
/**
- * ModuleResolution_attribute.
- * This attribute is specific to the OpenJDK and may change in the future.
- *
+ * A ModuleResolution attribute. This attribute is specific to the OpenJDK and may change in the
+ * future.
+ *
* @author Remi Forax
*/
public final class ModuleResolutionAttribute extends Attribute {
- /**
- * Resolution state of a module meaning that the module is not available
- * from the class-path by default.
- */
- public static final int RESOLUTION_DO_NOT_RESOLVE_BY_DEFAULT = 1;
-
- /**
- * Resolution state of a module meaning the module is marked as deprecated.
- */
- public static final int RESOLUTION_WARN_DEPRECATED = 2;
-
- /**
- * Resolution state of a module meaning the module is marked as deprecated
- * and will be removed in a future release.
- */
- public static final int RESOLUTION_WARN_DEPRECATED_FOR_REMOVAL = 4;
-
- /**
- * Resolution state of a module meaning the module is not yet standardized,
- * so in incubating mode.
- */
- public static final int RESOLUTION_WARN_INCUBATING = 8;
-
- public int resolution;
-
- /**
- * Creates an attribute with a resolution state value.
- * @param resolution the resolution state among
- * {@link #RESOLUTION_WARN_DEPRECATED},
- * {@link #RESOLUTION_WARN_DEPRECATED_FOR_REMOVAL}, and
- * {@link #RESOLUTION_WARN_INCUBATING}.
- */
- public ModuleResolutionAttribute(final int resolution) {
- super("ModuleResolution");
- this.resolution = resolution;
- }
-
- /**
- * Creates an empty attribute that can be used as prototype
- * to be passed as argument of the method
- * {@link ClassReader#accept(org.objectweb.asm.ClassVisitor, Attribute[], int)}.
- */
- public ModuleResolutionAttribute() {
- this(0);
- }
-
- @Override
- protected Attribute read(ClassReader cr, int off, int len, char[] buf,
- int codeOff, Label[] labels) {
- int resolution = cr.readUnsignedShort(off);
- return new ModuleResolutionAttribute(resolution);
- }
-
- @Override
- protected ByteVector write(ClassWriter cw, byte[] code, int len,
- int maxStack, int maxLocals) {
- ByteVector v = new ByteVector();
- v.putShort(resolution);
- return v;
- }
+ /**
+ * The resolution state of a module meaning that the module is not available from the class-path
+ * by default.
+ */
+ public static final int RESOLUTION_DO_NOT_RESOLVE_BY_DEFAULT = 1;
+
+ /** The resolution state of a module meaning the module is marked as deprecated. */
+ public static final int RESOLUTION_WARN_DEPRECATED = 2;
+
+ /**
+ * The resolution state of a module meaning the module is marked as deprecated and will be removed
+ * in a future release.
+ */
+ public static final int RESOLUTION_WARN_DEPRECATED_FOR_REMOVAL = 4;
+
+ /**
+ * The resolution state of a module meaning the module is not yet standardized, so in incubating
+ * mode.
+ */
+ public static final int RESOLUTION_WARN_INCUBATING = 8;
+
+ /**
+ * The resolution state of the module. Must be one of {@link #RESOLUTION_WARN_DEPRECATED}, {@link
+ * #RESOLUTION_WARN_DEPRECATED_FOR_REMOVAL}, and {@link #RESOLUTION_WARN_INCUBATING}.
+ */
+ public int resolution;
+
+ /**
+ * Constructs a new {@link ModuleResolutionAttribute}.
+ *
+ * @param resolution the resolution state of the module. Must be one of {@link
+ * #RESOLUTION_WARN_DEPRECATED}, {@link #RESOLUTION_WARN_DEPRECATED_FOR_REMOVAL}, and {@link
+ * #RESOLUTION_WARN_INCUBATING}.
+ */
+ public ModuleResolutionAttribute(final int resolution) {
+ super("ModuleResolution");
+ this.resolution = resolution;
+ }
+
+ /**
+ * Constructs an empty {@link ModuleResolutionAttribute}. This object can be passed as a prototype
+ * to the {@link ClassReader#accept(org.apache.tapestry5.internal.plastic.asm.ClassVisitor, Attribute[], int)} method.
+ */
+ public ModuleResolutionAttribute() {
+ this(0);
+ }
+
+ @Override
+ protected Attribute read(
+ final ClassReader classReader,
+ final int offset,
+ final int length,
+ final char[] charBuffer,
+ final int codeOffset,
+ final Label[] labels) {
+ return new ModuleResolutionAttribute(classReader.readUnsignedShort(offset));
+ }
+
+ @Override
+ protected ByteVector write(
+ final ClassWriter classWriter,
+ final byte[] code,
+ final int codeLength,
+ final int maxStack,
+ final int maxLocals) {
+ ByteVector byteVector = new ByteVector();
+ byteVector.putShort(resolution);
+ return byteVector;
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/1c71aec7/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleTargetAttribute.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleTargetAttribute.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleTargetAttribute.java
old mode 100644
new mode 100755
index 02feb7a..d48b5b1
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleTargetAttribute.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/commons/ModuleTargetAttribute.java
@@ -1,32 +1,30 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
+// ASM: a very small and fast Java bytecode manipulation framework
+// Copyright (c) 2000-2011 INRIA, France Telecom
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. Neither the name of the copyright holders nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
package org.apache.tapestry5.internal.plastic.asm.commons;
@@ -37,45 +35,53 @@ import org.apache.tapestry5.internal.plastic.asm.ClassWriter;
import org.apache.tapestry5.internal.plastic.asm.Label;
/**
- * ModuleTarget attribute.
- * This attribute is specific to the OpenJDK and may change in the future.
- *
+ * A ModuleTarget attribute. This attribute is specific to the OpenJDK and may change in the future.
+ *
* @author Remi Forax
*/
public final class ModuleTargetAttribute extends Attribute {
- public String platform;
-
- /**
- * Creates an attribute with a platform name.
- * @param platform the platform name on which the module can run.
- */
- public ModuleTargetAttribute(final String platform) {
- super("ModuleTarget");
- this.platform = platform;
- }
-
- /**
- * Creates an empty attribute that can be used as prototype
- * to be passed as argument of the method
- * {@link ClassReader#accept(org.objectweb.asm.ClassVisitor, Attribute[], int)}.
- */
- public ModuleTargetAttribute() {
- this(null);
- }
-
- @Override
- protected Attribute read(ClassReader cr, int off, int len, char[] buf,
- int codeOff, Label[] labels) {
- String platform = cr.readUTF8(off, buf);
- return new ModuleTargetAttribute(platform);
- }
-
- @Override
- protected ByteVector write(ClassWriter cw, byte[] code, int len,
- int maxStack, int maxLocals) {
- ByteVector v = new ByteVector();
- int index = (platform == null)? 0: cw.newUTF8(platform);
- v.putShort(index);
- return v;
- }
+
+ /** The name of the platform on which the module can run. */
+ public String platform;
+
+ /**
+ * Constructs a new {@link ModuleTargetAttribute}.
+ *
+ * @param platform the name of the platform on which the module can run.
+ */
+ public ModuleTargetAttribute(final String platform) {
+ super("ModuleTarget");
+ this.platform = platform;
+ }
+
+ /**
+ * Constructs an empty {@link ModuleTargetAttribute}. This object can be passed as a prototype to
+ * the {@link ClassReader#accept(org.apache.tapestry5.internal.plastic.asm.ClassVisitor, Attribute[], int)} method.
+ */
+ public ModuleTargetAttribute() {
+ this(null);
+ }
+
+ @Override
+ protected Attribute read(
+ final ClassReader classReader,
+ final int offset,
+ final int length,
+ final char[] charBuffer,
+ final int codeOffset,
+ final Label[] labels) {
+ return new ModuleTargetAttribute(classReader.readUTF8(offset, charBuffer));
+ }
+
+ @Override
+ protected ByteVector write(
+ final ClassWriter classWriter,
+ final byte[] code,
+ final int codeLength,
+ final int maxStack,
+ final int maxLocals) {
+ ByteVector byteVector = new ByteVector();
+ byteVector.putShort(platform == null ? 0 : classWriter.newUTF8(platform));
+ return byteVector;
+ }
}