diff --git a/jersey-server/src/main/java/com/sun/jersey/spi/scanning/AnnotationScannerListener.java b/jersey-server/src/main/java/com/sun/jersey/spi/scanning/AnnotationScannerListener.java
index 4025bb0a0..753da1c01 100644
--- a/jersey-server/src/main/java/com/sun/jersey/spi/scanning/AnnotationScannerListener.java
+++ b/jersey-server/src/main/java/com/sun/jersey/spi/scanning/AnnotationScannerListener.java
@@ -39,19 +39,9 @@
*/
package com.sun.jersey.spi.scanning;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
import com.sun.jersey.core.osgi.OsgiRegistry;
import com.sun.jersey.core.reflection.ReflectionHelper;
import com.sun.jersey.core.spi.scanning.ScannerListener;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-
import jersey.repackaged.org.objectweb.asm.AnnotationVisitor;
import jersey.repackaged.org.objectweb.asm.Attribute;
import jersey.repackaged.org.objectweb.asm.ClassReader;
@@ -60,6 +50,15 @@
import jersey.repackaged.org.objectweb.asm.MethodVisitor;
import jersey.repackaged.org.objectweb.asm.Opcodes;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
/**
* A scanner listener that processes Java class files (resource names
* ending in ".class") annotated with one or more of a set of declared
@@ -156,7 +155,7 @@ private final class AnnotatedClassVisitor extends ClassVisitor {
private boolean isAnnotated;
private AnnotatedClassVisitor() {
- super(Opcodes.ASM5);
+ super(Opcodes.ASM6);
}
public void visit(int version, int access, String name,
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java
index 83a1c97e5..2d82497bd 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java
@@ -33,7 +33,7 @@
* A visitor to visit a Java annotation. The methods of this class must be
* called in the following order: ( visit | visitEnum |
* visitAnnotation | visitArray )* visitEnd.
- *
+ *
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
@@ -41,7 +41,7 @@ public abstract class AnnotationVisitor {
/**
* The ASM API version implemented by this visitor. The value of this field
- * must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
+ * must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
*/
protected final int api;
@@ -53,10 +53,10 @@ public abstract class AnnotationVisitor {
/**
* Constructs a new {@link AnnotationVisitor}.
- *
+ *
* @param api
* the ASM API version implemented by this visitor. Must be one
- * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
+ * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
*/
public AnnotationVisitor(final int api) {
this(api, null);
@@ -64,16 +64,16 @@ public AnnotationVisitor(final int api) {
/**
* Constructs a new {@link AnnotationVisitor}.
- *
+ *
* @param api
* the ASM API version implemented by this visitor. Must be one
- * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
+ * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
* @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 && api != Opcodes.ASM5) {
+ if (api < Opcodes.ASM4 || api > Opcodes.ASM6) {
throw new IllegalArgumentException();
}
this.api = api;
@@ -82,14 +82,14 @@ public AnnotationVisitor(final int api, final AnnotationVisitor 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} or OBJECT or ARRAY sort. This
+ * {@link String} or {@link Type} of 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
@@ -103,7 +103,7 @@ public void visit(String name, Object value) {
/**
* Visits an enumeration value of the annotation.
- *
+ *
* @param name
* the value name.
* @param desc
@@ -119,7 +119,7 @@ public void visitEnum(String name, String desc, String value) {
/**
* Visits a nested annotation value of the annotation.
- *
+ *
* @param name
* the value name.
* @param desc
@@ -142,7 +142,7 @@ public AnnotationVisitor visitAnnotation(String name, String desc) {
* 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
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationWriter.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationWriter.java
index 7926a1af5..8011f42e2 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationWriter.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationWriter.java
@@ -31,7 +31,7 @@
/**
* An {@link AnnotationVisitor} that generates annotations in bytecode form.
- *
+ *
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
@@ -89,7 +89,7 @@ final class AnnotationWriter extends AnnotationVisitor {
/**
* Constructs a new {@link AnnotationWriter}.
- *
+ *
* @param cw
* the class writer to which this annotation must be added.
* @param named
@@ -104,7 +104,7 @@ final class AnnotationWriter extends AnnotationVisitor {
*/
AnnotationWriter(final ClassWriter cw, final boolean named,
final ByteVector bv, final ByteVector parent, final int offset) {
- super(Opcodes.ASM5);
+ super(Opcodes.ASM6);
this.cw = cw;
this.named = named;
this.bv = bv;
@@ -237,7 +237,7 @@ public void visitEnd() {
/**
* Returns the size of this annotation writer list.
- *
+ *
* @return the size of this annotation writer list.
*/
int getSize() {
@@ -253,7 +253,7 @@ int getSize() {
/**
* Puts the annotations of this annotation writer list into the given byte
* vector.
- *
+ *
* @param out
* where the annotations must be put.
*/
@@ -281,7 +281,7 @@ void put(final ByteVector out) {
/**
* Puts the given annotation lists into the given byte vector.
- *
+ *
* @param panns
* an array of annotation writer lists.
* @param off
@@ -319,7 +319,7 @@ static void put(final AnnotationWriter[] panns, final int off,
/**
* Puts the given type reference and type path into the given bytevector.
* LOCAL_VARIABLE and RESOURCE_VARIABLE target types are not supported.
- *
+ *
* @param typeRef
* a reference to the annotated type. See {@link TypeReference}.
* @param typePath
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java
index a86ec0978..5ef8d9d0a 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java
@@ -31,7 +31,7 @@
/**
* 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.
*/
@@ -65,7 +65,7 @@ protected Attribute(final String type) {
/**
* Returns true if this type of attribute is unknown. The default
* implementation of this method always returns true.
- *
+ *
* @return true if this type of attribute is unknown.
*/
public boolean isUnknown() {
@@ -74,7 +74,7 @@ public boolean isUnknown() {
/**
* Returns true if this type of attribute is a code attribute.
- *
+ *
* @return true if this type of attribute is a code attribute.
*/
public boolean isCodeAttribute() {
@@ -83,7 +83,7 @@ public boolean isCodeAttribute() {
/**
* Returns the labels corresponding to this attribute.
- *
+ *
* @return the labels corresponding to this attribute, or null if
* this attribute is not a code attribute that contains labels.
*/
@@ -96,7 +96,7 @@ protected Label[] getLabels() {
* new {@link Attribute} object, of type {@link #type type},
* corresponding to the len bytes starting at the given offset, in
* the given class reader.
- *
+ *
* @param cr
* the class that contains the attribute to be read.
* @param off
@@ -133,7 +133,7 @@ protected Attribute read(final ClassReader cr, final int off,
/**
* 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
@@ -166,7 +166,7 @@ protected ByteVector write(final ClassWriter cw, final byte[] code,
/**
* 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() {
@@ -181,7 +181,7 @@ final int getCount() {
/**
* 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.
@@ -219,7 +219,7 @@ final int getSize(final ClassWriter cw, final byte[] code, final int len,
/**
* 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.
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ByteVector.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ByteVector.java
index 654985299..2fc3e5a8c 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ByteVector.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ByteVector.java
@@ -32,7 +32,7 @@
/**
* 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 ByteVector() {
/**
* Constructs a new {@link ByteVector ByteVector} with the given initial
* size.
- *
+ *
* @param initialSize
* the initial size of the byte vector to be constructed.
*/
@@ -69,7 +69,7 @@ public ByteVector(final int initialSize) {
/**
* Puts a byte into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param b
* a byte.
* @return this byte vector.
@@ -87,7 +87,7 @@ public ByteVector putByte(final int b) {
/**
* Puts two bytes into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param b1
* a byte.
* @param b2
@@ -109,7 +109,7 @@ ByteVector put11(final int b1, final int b2) {
/**
* Puts a short into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param s
* a short.
* @return this byte vector.
@@ -129,7 +129,7 @@ public ByteVector putShort(final int s) {
/**
* Puts a byte and a short into this byte vector. The byte vector is
* automatically enlarged if necessary.
- *
+ *
* @param b
* a byte.
* @param s
@@ -152,7 +152,7 @@ ByteVector put12(final int b, final int s) {
/**
* Puts an int into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param i
* an int.
* @return this byte vector.
@@ -174,7 +174,7 @@ public ByteVector putInt(final int i) {
/**
* Puts a long into this byte vector. The byte vector is automatically
* enlarged if necessary.
- *
+ *
* @param l
* a long.
* @return this byte vector.
@@ -202,7 +202,7 @@ public ByteVector putLong(final long l) {
/**
* Puts an UTF8 string into this byte vector. The byte vector is
* automatically enlarged if necessary.
- *
+ *
* @param s
* a String whose UTF8 encoded length must be less than 65536.
* @return this byte vector.
@@ -243,7 +243,7 @@ public ByteVector putUTF8(final String s) {
* automatically enlarged if necessary. The string length is encoded in two
* bytes before the encoded characters, if there is space for that (i.e. if
* this.length - i - 2 >= 0).
- *
+ *
* @param s
* the String to encode.
* @param i
@@ -301,7 +301,7 @@ ByteVector encodeUTF8(final String s, int i, int maxByteLength) {
/**
* 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 null to put len
* null bytes into this byte vector.
@@ -324,7 +324,7 @@ public ByteVector putByteArray(final byte[] b, final int off, final int len) {
/**
* 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.
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java
index 9f7ed33fa..c095e2692 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java
@@ -37,37 +37,12 @@
* 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
*/
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
* attribute won't be visited. This can be used, for example, to retrieve
@@ -104,6 +79,21 @@ public class ClassReader {
*/
public static final int EXPAND_FRAMES = 8;
+ /**
+ * Flag to expand the ASM pseudo instructions into an equivalent sequence of
+ * standard bytecode instructions. When resolving a forward jump it may
+ * happen that the signed 2 bytes offset reserved for it is not sufficient
+ * to store the bytecode offset. In this case the jump instruction is
+ * replaced with a temporary ASM pseudo instruction using an unsigned 2
+ * bytes offset (see Label#resolve). This internal flag is used to re-read
+ * classes containing such instructions, in order to replace them with
+ * standard instructions. In addition, when this flag is used, GOTO_W and
+ * JSR_W are not converted into GOTO and JSR, to make sure that
+ * infinite loops where a GOTO_W is replaced with a GOTO in ClassReader and
+ * converted back to a GOTO_W in ClassWriter cannot occur.
+ */
+ static final int EXPAND_ASM_INSNS = 256;
+
/**
* The class to be parsed. The content of this array must not be
* modified. This field is intended for {@link Attribute} sub classes, and
@@ -145,7 +135,7 @@ public class ClassReader {
/**
* Constructs a new {@link ClassReader} object.
- *
+ *
* @param b
* the bytecode of the class to be read.
*/
@@ -155,7 +145,7 @@ public ClassReader(final byte[] b) {
/**
* Constructs a new {@link ClassReader} object.
- *
+ *
* @param b
* the bytecode of the class to be read.
* @param off
@@ -166,7 +156,7 @@ public ClassReader(final byte[] b) {
public ClassReader(final byte[] b, final int off, final int len) {
this.b = b;
// checks the class version
- if (readShort(off + 6) > Opcodes.V1_8) {
+ if (readShort(off + 6) > Opcodes.V9) {
throw new IllegalArgumentException();
}
// parses the constant pool
@@ -205,6 +195,8 @@ public ClassReader(final byte[] b, final int off, final int len) {
// case ClassWriter.CLASS:
// case ClassWriter.STR:
// case ClassWriter.MTYPE
+ // case ClassWriter.PACKAGE:
+ // case ClassWriter.MODULE:
default:
size = 3;
break;
@@ -220,9 +212,9 @@ public ClassReader(final byte[] b, final int off, final int len) {
* 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() {
@@ -232,9 +224,9 @@ public int getAccess() {
/**
* 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() {
@@ -245,10 +237,10 @@ public String getClassName() {
* 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 null for
* {@link Object} class.
- *
+ *
* @see ClassVisitor#visit(int, int, String, String, String, String[])
*/
public String getSuperName() {
@@ -258,10 +250,10 @@ public String getSuperName() {
/**
* 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
* null.
- *
+ *
* @see ClassVisitor#visit(int, int, String, String, String, String[])
*/
public String[] getInterfaces() {
@@ -281,7 +273,7 @@ public String[] getInterfaces() {
/**
* 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.
*/
@@ -348,7 +340,9 @@ void copyPool(final ClassWriter classWriter) {
break;
// case ClassWriter.STR:
// case ClassWriter.CLASS:
- // case ClassWriter.MTYPE
+ // case ClassWriter.MTYPE:
+ // case ClassWriter.MODULE:
+ // case ClassWriter.PACKAGE:
default:
item.set(tag, readUTF8(index, buf), null, null);
break;
@@ -369,7 +363,7 @@ void copyPool(final ClassWriter classWriter) {
/**
* Copies the bootstrap method data into the given {@link ClassWriter}.
* Should be called before the {@link #accept(ClassVisitor,int)} method.
- *
+ *
* @param classWriter
* the {@link ClassWriter} to copy bootstrap methods into.
*/
@@ -414,7 +408,7 @@ private void copyBootstrapMethods(final ClassWriter classWriter,
/**
* Constructs a new {@link ClassReader} object.
- *
+ *
* @param is
* an input stream from which to read the class.
* @throws IOException
@@ -426,7 +420,7 @@ public ClassReader(final InputStream is) throws IOException {
/**
* Constructs a new {@link ClassReader} object.
- *
+ *
* @param name
* the binary qualified name of the class to be read.
* @throws IOException
@@ -440,7 +434,7 @@ public ClassReader(final String name) throws IOException {
/**
* Reads the bytecode of a class.
- *
+ *
* @param is
* an input stream from which to read the class.
* @param close
@@ -494,7 +488,7 @@ private static byte[] readClass(final InputStream is, boolean close)
* 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
@@ -510,7 +504,7 @@ public void accept(final ClassVisitor classVisitor, final int flags) {
* 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
@@ -555,11 +549,14 @@ public void accept(final ClassVisitor classVisitor,
String enclosingOwner = null;
String enclosingName = null;
String enclosingDesc = null;
+ String moduleMainClass = null;
int anns = 0;
int ianns = 0;
int tanns = 0;
int itanns = 0;
int innerClasses = 0;
+ int module = 0;
+ int packages = 0;
Attribute attributes = null;
u = getAttributes();
@@ -578,13 +575,11 @@ public void accept(final ClassVisitor classVisitor,
enclosingName = readUTF8(items[item], c);
enclosingDesc = readUTF8(items[item] + 2, c);
}
- } else if (SIGNATURES && "Signature".equals(attrName)) {
+ } else if ("Signature".equals(attrName)) {
signature = readUTF8(u + 8, c);
- } else if (ANNOTATIONS
- && "RuntimeVisibleAnnotations".equals(attrName)) {
+ } else if ("RuntimeVisibleAnnotations".equals(attrName)) {
anns = u + 8;
- } else if (ANNOTATIONS
- && "RuntimeVisibleTypeAnnotations".equals(attrName)) {
+ } else if ("RuntimeVisibleTypeAnnotations".equals(attrName)) {
tanns = u + 8;
} else if ("Deprecated".equals(attrName)) {
access |= Opcodes.ACC_DEPRECATED;
@@ -594,12 +589,16 @@ public void accept(final ClassVisitor classVisitor,
} else if ("SourceDebugExtension".equals(attrName)) {
int len = readInt(u + 4);
sourceDebug = readUTF(u + 8, len, new char[len]);
- } else if (ANNOTATIONS
- && "RuntimeInvisibleAnnotations".equals(attrName)) {
+ } else if ("RuntimeInvisibleAnnotations".equals(attrName)) {
ianns = u + 8;
- } else if (ANNOTATIONS
- && "RuntimeInvisibleTypeAnnotations".equals(attrName)) {
+ } else if ("RuntimeInvisibleTypeAnnotations".equals(attrName)) {
itanns = u + 8;
+ } else if ("Module".equals(attrName)) {
+ module = u + 8;
+ } else if ("ModuleMainClass".equals(attrName)) {
+ moduleMainClass = readClass(u + 8, c);
+ } else if ("ModulePackages".equals(attrName)) {
+ packages = u + 10;
} else if ("BootstrapMethods".equals(attrName)) {
int[] bootstrapMethods = new int[readUnsignedShort(u + 8)];
for (int j = 0, v = u + 10; j < bootstrapMethods.length; j++) {
@@ -628,6 +627,12 @@ public void accept(final ClassVisitor classVisitor,
classVisitor.visitSource(sourceFile, sourceDebug);
}
+ // visits the module info and associated attributes
+ if (module != 0) {
+ readModule(classVisitor, context, module,
+ moduleMainClass, packages);
+ }
+
// visits the outer class
if (enclosingOwner != null) {
classVisitor.visitOuterClass(enclosingOwner, enclosingName,
@@ -635,19 +640,19 @@ public void accept(final ClassVisitor classVisitor,
}
// visits the class annotations and type annotations
- if (ANNOTATIONS && anns != 0) {
+ if (anns != 0) {
for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) {
v = readAnnotationValues(v + 2, c, true,
classVisitor.visitAnnotation(readUTF8(v, c), true));
}
}
- if (ANNOTATIONS && ianns != 0) {
+ if (ianns != 0) {
for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) {
v = readAnnotationValues(v + 2, c, true,
classVisitor.visitAnnotation(readUTF8(v, c), false));
}
}
- if (ANNOTATIONS && tanns != 0) {
+ if (tanns != 0) {
for (int i = readUnsignedShort(tanns), v = tanns + 2; i > 0; --i) {
v = readAnnotationTarget(context, v);
v = readAnnotationValues(v + 2, c, true,
@@ -655,7 +660,7 @@ public void accept(final ClassVisitor classVisitor,
context.typePath, readUTF8(v, c), true));
}
}
- if (ANNOTATIONS && itanns != 0) {
+ if (itanns != 0) {
for (int i = readUnsignedShort(itanns), v = itanns + 2; i > 0; --i) {
v = readAnnotationTarget(context, v);
v = readAnnotationValues(v + 2, c, true,
@@ -697,9 +702,123 @@ public void accept(final ClassVisitor classVisitor,
classVisitor.visitEnd();
}
+ /**
+ * Reads the module attribute and visit it.
+ *
+ * @param classVisitor
+ * the current class visitor
+ * @param context
+ * information about the class being parsed.
+ * @param u
+ * start offset of the module attribute in the class file.
+ * @param mainClass
+ * name of the main class of a module or null.
+ * @param packages
+ * start offset of the concealed package attribute.
+ */
+ private void readModule(final ClassVisitor classVisitor,
+ final Context context, int u,
+ final String mainClass, int packages) {
+
+ char[] buffer = context.buffer;
+
+ // reads module name, flags and version
+ String name = readModule(u, buffer);
+ int flags = readUnsignedShort(u + 2);
+ String version = readUTF8(u + 4, buffer);
+ u += 6;
+
+ ModuleVisitor mv = classVisitor.visitModule(name, flags, version);
+ if (mv == null) {
+ return;
+ }
+
+ // module attributes (main class, packages)
+ if (mainClass != null) {
+ mv.visitMainClass(mainClass);
+ }
+
+ if (packages != 0) {
+ for (int i = readUnsignedShort(packages - 2); i > 0; --i) {
+ String packaze = readPackage(packages, buffer);
+ mv.visitPackage(packaze);
+ packages += 2;
+ }
+ }
+
+ // reads requires
+ u += 2;
+ for (int i = readUnsignedShort(u - 2); i > 0; --i) {
+ String module = readModule(u, buffer);
+ int access = readUnsignedShort(u + 2);
+ String requireVersion = readUTF8(u + 4, buffer);
+ mv.visitRequire(module, access, requireVersion);
+ u += 6;
+ }
+
+ // reads exports
+ u += 2;
+ for (int i = readUnsignedShort(u - 2); i > 0; --i) {
+ String export = readPackage(u, buffer);
+ int access = readUnsignedShort(u + 2);
+ int exportToCount = readUnsignedShort(u + 4);
+ u += 6;
+ String[] tos = null;
+ if (exportToCount != 0) {
+ tos = new String[exportToCount];
+ for (int j = 0; j < tos.length; ++j) {
+ tos[j] = readModule(u, buffer);
+ u += 2;
+ }
+ }
+ mv.visitExport(export, access, tos);
+ }
+
+ // reads opens
+ u += 2;
+ for (int i = readUnsignedShort(u - 2); i > 0; --i) {
+ String open = readPackage(u, buffer);
+ int access = readUnsignedShort(u + 2);
+ int openToCount = readUnsignedShort(u + 4);
+ u += 6;
+ String[] tos = null;
+ if (openToCount != 0) {
+ tos = new String[openToCount];
+ for (int j = 0; j < tos.length; ++j) {
+ tos[j] = readModule(u, buffer);
+ u += 2;
+ }
+ }
+ mv.visitOpen(open, access, tos);
+ }
+
+ // read uses
+ u += 2;
+ for (int i = readUnsignedShort(u - 2); i > 0; --i) {
+ mv.visitUse(readClass(u, buffer));
+ u += 2;
+ }
+
+ // read provides
+ u += 2;
+ for (int i = readUnsignedShort(u - 2); i > 0; --i) {
+ String service = readClass(u, buffer);
+ int provideWithCount = readUnsignedShort(u + 2);
+ u += 4;
+ String[] withs = new String[provideWithCount];
+ for (int j = 0; j < withs.length; ++j) {
+ withs[j] = readClass(u, buffer);
+ u += 2;
+ }
+ mv.visitProvide(service, withs);
+ }
+
+ mv.visitEnd();
+ }
+
/**
* Reads a field and makes the given visitor visit it.
- *
+ *
* @param classVisitor
* the visitor that must visit the field.
* @param context
@@ -733,24 +852,20 @@ private int readField(final ClassVisitor classVisitor,
if ("ConstantValue".equals(attrName)) {
int item = readUnsignedShort(u + 8);
value = item == 0 ? null : readConst(item, c);
- } else if (SIGNATURES && "Signature".equals(attrName)) {
+ } else if ("Signature".equals(attrName)) {
signature = readUTF8(u + 8, c);
} else if ("Deprecated".equals(attrName)) {
access |= Opcodes.ACC_DEPRECATED;
} else if ("Synthetic".equals(attrName)) {
access |= Opcodes.ACC_SYNTHETIC
| ClassWriter.ACC_SYNTHETIC_ATTRIBUTE;
- } else if (ANNOTATIONS
- && "RuntimeVisibleAnnotations".equals(attrName)) {
+ } else if ("RuntimeVisibleAnnotations".equals(attrName)) {
anns = u + 8;
- } else if (ANNOTATIONS
- && "RuntimeVisibleTypeAnnotations".equals(attrName)) {
+ } else if ("RuntimeVisibleTypeAnnotations".equals(attrName)) {
tanns = u + 8;
- } else if (ANNOTATIONS
- && "RuntimeInvisibleAnnotations".equals(attrName)) {
+ } else if ("RuntimeInvisibleAnnotations".equals(attrName)) {
ianns = u + 8;
- } else if (ANNOTATIONS
- && "RuntimeInvisibleTypeAnnotations".equals(attrName)) {
+ } else if ("RuntimeInvisibleTypeAnnotations".equals(attrName)) {
itanns = u + 8;
} else {
Attribute attr = readAttribute(context.attrs, attrName, u + 8,
@@ -772,19 +887,19 @@ private int readField(final ClassVisitor classVisitor,
}
// visits the field annotations and type annotations
- if (ANNOTATIONS && anns != 0) {
+ if (anns != 0) {
for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) {
v = readAnnotationValues(v + 2, c, true,
fv.visitAnnotation(readUTF8(v, c), true));
}
}
- if (ANNOTATIONS && ianns != 0) {
+ if (ianns != 0) {
for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) {
v = readAnnotationValues(v + 2, c, true,
fv.visitAnnotation(readUTF8(v, c), false));
}
}
- if (ANNOTATIONS && tanns != 0) {
+ if (tanns != 0) {
for (int i = readUnsignedShort(tanns), v = tanns + 2; i > 0; --i) {
v = readAnnotationTarget(context, v);
v = readAnnotationValues(v + 2, c, true,
@@ -792,7 +907,7 @@ private int readField(final ClassVisitor classVisitor,
context.typePath, readUTF8(v, c), true));
}
}
- if (ANNOTATIONS && itanns != 0) {
+ if (itanns != 0) {
for (int i = readUnsignedShort(itanns), v = itanns + 2; i > 0; --i) {
v = readAnnotationTarget(context, v);
v = readAnnotationValues(v + 2, c, true,
@@ -817,7 +932,7 @@ private int readField(final ClassVisitor classVisitor,
/**
* Reads a method and makes the given visitor visit it.
- *
+ *
* @param classVisitor
* the visitor that must visit the method.
* @param context
@@ -866,32 +981,26 @@ private int readMethod(final ClassVisitor classVisitor,
exceptions[j] = readClass(exception, c);
exception += 2;
}
- } else if (SIGNATURES && "Signature".equals(attrName)) {
+ } else if ("Signature".equals(attrName)) {
signature = readUTF8(u + 8, c);
} else if ("Deprecated".equals(attrName)) {
context.access |= Opcodes.ACC_DEPRECATED;
- } else if (ANNOTATIONS
- && "RuntimeVisibleAnnotations".equals(attrName)) {
+ } else if ("RuntimeVisibleAnnotations".equals(attrName)) {
anns = u + 8;
- } else if (ANNOTATIONS
- && "RuntimeVisibleTypeAnnotations".equals(attrName)) {
+ } else if ("RuntimeVisibleTypeAnnotations".equals(attrName)) {
tanns = u + 8;
- } else if (ANNOTATIONS && "AnnotationDefault".equals(attrName)) {
+ } else if ("AnnotationDefault".equals(attrName)) {
dann = u + 8;
} else if ("Synthetic".equals(attrName)) {
context.access |= Opcodes.ACC_SYNTHETIC
| ClassWriter.ACC_SYNTHETIC_ATTRIBUTE;
- } else if (ANNOTATIONS
- && "RuntimeInvisibleAnnotations".equals(attrName)) {
+ } else if ("RuntimeInvisibleAnnotations".equals(attrName)) {
ianns = u + 8;
- } else if (ANNOTATIONS
- && "RuntimeInvisibleTypeAnnotations".equals(attrName)) {
+ } else if ("RuntimeInvisibleTypeAnnotations".equals(attrName)) {
itanns = u + 8;
- } else if (ANNOTATIONS
- && "RuntimeVisibleParameterAnnotations".equals(attrName)) {
+ } else if ("RuntimeVisibleParameterAnnotations".equals(attrName)) {
mpanns = u + 8;
- } else if (ANNOTATIONS
- && "RuntimeInvisibleParameterAnnotations".equals(attrName)) {
+ } else if ("RuntimeInvisibleParameterAnnotations".equals(attrName)) {
impanns = u + 8;
} else if ("MethodParameters".equals(attrName)) {
methodParameters = u + 8;
@@ -924,7 +1033,7 @@ private int readMethod(final ClassVisitor classVisitor,
* access, name and descriptor can have been changed, this is not
* important since they are not copied as is from the reader).
*/
- if (WRITER && mv instanceof MethodWriter) {
+ if (mv instanceof MethodWriter) {
MethodWriter mw = (MethodWriter) mv;
if (mw.cw.cr == this && signature == mw.signature) {
boolean sameExceptions = false;
@@ -961,26 +1070,26 @@ private int readMethod(final ClassVisitor classVisitor,
}
// visits the method annotations
- if (ANNOTATIONS && dann != 0) {
+ if (dann != 0) {
AnnotationVisitor dv = mv.visitAnnotationDefault();
readAnnotationValue(dann, c, null, dv);
if (dv != null) {
dv.visitEnd();
}
}
- if (ANNOTATIONS && anns != 0) {
+ if (anns != 0) {
for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) {
v = readAnnotationValues(v + 2, c, true,
mv.visitAnnotation(readUTF8(v, c), true));
}
}
- if (ANNOTATIONS && ianns != 0) {
+ if (ianns != 0) {
for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) {
v = readAnnotationValues(v + 2, c, true,
mv.visitAnnotation(readUTF8(v, c), false));
}
}
- if (ANNOTATIONS && tanns != 0) {
+ if (tanns != 0) {
for (int i = readUnsignedShort(tanns), v = tanns + 2; i > 0; --i) {
v = readAnnotationTarget(context, v);
v = readAnnotationValues(v + 2, c, true,
@@ -988,7 +1097,7 @@ private int readMethod(final ClassVisitor classVisitor,
context.typePath, readUTF8(v, c), true));
}
}
- if (ANNOTATIONS && itanns != 0) {
+ if (itanns != 0) {
for (int i = readUnsignedShort(itanns), v = itanns + 2; i > 0; --i) {
v = readAnnotationTarget(context, v);
v = readAnnotationValues(v + 2, c, true,
@@ -996,10 +1105,10 @@ private int readMethod(final ClassVisitor classVisitor,
context.typePath, readUTF8(v, c), false));
}
}
- if (ANNOTATIONS && mpanns != 0) {
+ if (mpanns != 0) {
readParameterAnnotations(mv, context, mpanns, true);
}
- if (ANNOTATIONS && impanns != 0) {
+ if (impanns != 0) {
readParameterAnnotations(mv, context, impanns, false);
}
@@ -1025,7 +1134,7 @@ private int readMethod(final ClassVisitor classVisitor,
/**
* Reads the bytecode of a method and makes the given visitor visit it.
- *
+ *
* @param mv
* the visitor that must visit the method's code.
* @param context
@@ -1046,7 +1155,7 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
int codeStart = u;
int codeEnd = u + codeLength;
Label[] labels = context.labels = new Label[codeLength + 2];
- readLabel(codeLength + 1, labels);
+ createLabel(codeLength + 1, labels);
while (u < codeEnd) {
int offset = u - codeStart;
int opcode = b[u] & 0xFF;
@@ -1056,11 +1165,16 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
u += 1;
break;
case ClassWriter.LABEL_INSN:
- readLabel(offset + readShort(u + 1), labels);
+ createLabel(offset + readShort(u + 1), labels);
+ u += 3;
+ break;
+ case ClassWriter.ASM_LABEL_INSN:
+ createLabel(offset + readUnsignedShort(u + 1), labels);
u += 3;
break;
case ClassWriter.LABELW_INSN:
- readLabel(offset + readInt(u + 1), labels);
+ case ClassWriter.ASM_LABELW_INSN:
+ createLabel(offset + readInt(u + 1), labels);
u += 5;
break;
case ClassWriter.WIDE_INSN:
@@ -1075,9 +1189,9 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
// skips 0 to 3 padding bytes
u = u + 4 - (offset & 3);
// reads instruction
- readLabel(offset + readInt(u), labels);
+ createLabel(offset + readInt(u), labels);
for (int i = readInt(u + 8) - readInt(u + 4) + 1; i > 0; --i) {
- readLabel(offset + readInt(u + 12), labels);
+ createLabel(offset + readInt(u + 12), labels);
u += 4;
}
u += 12;
@@ -1086,9 +1200,9 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
// skips 0 to 3 padding bytes
u = u + 4 - (offset & 3);
// reads instruction
- readLabel(offset + readInt(u), labels);
+ createLabel(offset + readInt(u), labels);
for (int i = readInt(u + 4); i > 0; --i) {
- readLabel(offset + readInt(u + 12), labels);
+ createLabel(offset + readInt(u + 12), labels);
u += 8;
}
u += 8;
@@ -1118,9 +1232,9 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
// reads the try catch entries to find the labels, and also visits them
for (int i = readUnsignedShort(u); i > 0; --i) {
- Label start = readLabel(readUnsignedShort(u + 2), labels);
- Label end = readLabel(readUnsignedShort(u + 4), labels);
- Label handler = readLabel(readUnsignedShort(u + 6), labels);
+ Label start = createLabel(readUnsignedShort(u + 2), labels);
+ Label end = createLabel(readUnsignedShort(u + 4), labels);
+ Label handler = createLabel(readUnsignedShort(u + 6), labels);
String type = readUTF8(items[readUnsignedShort(u + 8)], c);
mv.visitTryCatchBlock(start, end, handler, type);
u += 8;
@@ -1151,13 +1265,9 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
varTable = u + 8;
for (int j = readUnsignedShort(u + 8), v = u; j > 0; --j) {
int label = readUnsignedShort(v + 10);
- if (labels[label] == null) {
- readLabel(label, labels).status |= Label.DEBUG;
- }
+ createDebugLabel(label, labels);
label += readUnsignedShort(v + 12);
- if (labels[label] == null) {
- readLabel(label, labels).status |= Label.DEBUG;
- }
+ createDebugLabel(label, labels);
v += 10;
}
}
@@ -1167,24 +1277,27 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
if ((context.flags & SKIP_DEBUG) == 0) {
for (int j = readUnsignedShort(u + 8), v = u; j > 0; --j) {
int label = readUnsignedShort(v + 10);
- if (labels[label] == null) {
- readLabel(label, labels).status |= Label.DEBUG;
+ createDebugLabel(label, labels);
+ Label l = labels[label];
+ while (l.line > 0) {
+ if (l.next == null) {
+ l.next = new Label();
+ }
+ l = l.next;
}
- labels[label].line = readUnsignedShort(v + 12);
+ l.line = readUnsignedShort(v + 12);
v += 4;
}
}
- } else if (ANNOTATIONS
- && "RuntimeVisibleTypeAnnotations".equals(attrName)) {
+ } else if ("RuntimeVisibleTypeAnnotations".equals(attrName)) {
tanns = readTypeAnnotations(mv, context, u + 8, true);
ntoff = tanns.length == 0 || readByte(tanns[0]) < 0x43 ? -1
: readUnsignedShort(tanns[0] + 1);
- } else if (ANNOTATIONS
- && "RuntimeInvisibleTypeAnnotations".equals(attrName)) {
+ } else if ("RuntimeInvisibleTypeAnnotations".equals(attrName)) {
itanns = readTypeAnnotations(mv, context, u + 8, false);
nitoff = itanns.length == 0 || readByte(itanns[0]) < 0x43 ? -1
: readUnsignedShort(itanns[0] + 1);
- } else if (FRAMES && "StackMapTable".equals(attrName)) {
+ } else if ("StackMapTable".equals(attrName)) {
if ((context.flags & SKIP_FRAMES) == 0) {
stackMap = u + 10;
stackMapSize = readInt(u + 4);
@@ -1208,7 +1321,7 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
* this by parsing the stack map table without a full decoding
* (see below).
*/
- } else if (FRAMES && "StackMap".equals(attrName)) {
+ } else if ("StackMap".equals(attrName)) {
if ((context.flags & SKIP_FRAMES) == 0) {
zip = false;
stackMap = u + 10;
@@ -1237,7 +1350,7 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
u += 2;
// generates the first (implicit) stack map frame
- if (FRAMES && stackMap != 0) {
+ if (stackMap != 0) {
/*
* for the first explicit frame the offset is not offset_delta + 1
* but only offset_delta; setting the implicit frame offset to -1
@@ -1270,14 +1383,31 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
int v = readUnsignedShort(i + 1);
if (v >= 0 && v < codeLength) {
if ((b[codeStart + v] & 0xFF) == Opcodes.NEW) {
- readLabel(v, labels);
+ createLabel(v, labels);
}
}
}
}
}
+ if ((context.flags & EXPAND_ASM_INSNS) != 0
+ && (context.flags & EXPAND_FRAMES) != 0) {
+ // Expanding the ASM pseudo instructions can introduce F_INSERT
+ // frames, even if the method does not currently have any frame.
+ // Also these inserted frames must be computed by simulating the
+ // effect of the bytecode instructions one by one, starting from the
+ // first one and the last existing frame (or the implicit first
+ // one). Finally, due to the way MethodWriter computes this (with
+ // the compute = INSERTED_FRAMES option), MethodWriter needs to know
+ // maxLocals before the first instruction is visited. For all these
+ // reasons we always visit the implicit first frame in this case
+ // (passing only maxLocals - the rest can be and is computed in
+ // MethodWriter).
+ mv.visitFrame(Opcodes.F_NEW, maxLocals, null, 0, null);
+ }
// visits the instructions
+ int opcodeDelta = (context.flags & EXPAND_ASM_INSNS) == 0 ? -33 : 0;
+ boolean insertFrame = false;
u = codeStart;
while (u < codeEnd) {
int offset = u - codeStart;
@@ -1285,14 +1415,20 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
// visits the label and line number for this offset, if any
Label l = labels[offset];
if (l != null) {
+ Label next = l.next;
+ l.next = null;
mv.visitLabel(l);
if ((context.flags & SKIP_DEBUG) == 0 && l.line > 0) {
mv.visitLineNumber(l.line, l);
+ while (next != null) {
+ mv.visitLineNumber(next.line, l);
+ next = next.next;
+ }
}
}
// visits the frame for this offset, if any
- while (FRAMES && frame != null
+ while (frame != null
&& (frame.offset == offset || frame.offset == -1)) {
// if there is a frame for this offset, makes the visitor visit
// it, and reads the next frame if there is one.
@@ -1304,6 +1440,9 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
mv.visitFrame(frame.mode, frame.localDiff, frame.local,
frame.stackCount, frame.stack);
}
+ // if there is already a frame for this offset, there is no
+ // need to insert a new one.
+ insertFrame = false;
}
if (frameCount > 0) {
stackMap = readFrame(stackMap, zip, unzip, frame);
@@ -1312,6 +1451,13 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
frame = null;
}
}
+ // inserts a frame for this offset, if requested by setting
+ // insertFrame to true during the previous iteration. The actual
+ // frame content will be computed in MethodWriter.
+ if (insertFrame) {
+ mv.visitFrame(ClassWriter.F_INSERT, 0, null, 0, null);
+ insertFrame = false;
+ }
// visits the instruction at this offset
int opcode = b[u] & 0xFF;
@@ -1336,9 +1482,47 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
u += 3;
break;
case ClassWriter.LABELW_INSN:
- mv.visitJumpInsn(opcode - 33, labels[offset + readInt(u + 1)]);
+ mv.visitJumpInsn(opcode + opcodeDelta, labels[offset
+ + readInt(u + 1)]);
u += 5;
break;
+ case ClassWriter.ASM_LABEL_INSN: {
+ // changes temporary opcodes 202 to 217 (inclusive), 218
+ // and 219 to IFEQ ... JSR (inclusive), IFNULL and
+ // IFNONNULL
+ opcode = opcode < 218 ? opcode - 49 : opcode - 20;
+ Label target = labels[offset + readUnsignedShort(u + 1)];
+ // replaces GOTO with GOTO_W, JSR with JSR_W and IFxxx
+ //
*
- *
+ *
* @param classReader
* the {@link ClassReader} used to read the original class. It
* will be used to copy the entire constant pool from the
@@ -645,9 +677,9 @@ public ClassWriter(final int flags) {
* @param flags
* option flags that can be used to modify the default behavior
* of this class. These option flags do not affect methods
- * that are copied as is in the new class. This means that the
- * maximum stack size nor the stack frames will be computed for
- * these methods. See {@link #COMPUTE_MAXS},
+ * that are copied as is in the new class. This means that
+ * neither the maximum stack size nor the stack frames will be
+ * computed for these methods
+ * for a reference to a class:
* owner '.' name desc ' ' '(' tag ')'
+ * for a reference to an interface:
+ * owner '.' name desc ' ' '(' tag ' ' itf ')'
*
- *
+ *
* . As this format is unambiguous, it can be parsed if necessary.
*/
@Override
public String toString() {
- return owner + '.' + name + desc + " (" + tag + ')';
+ return owner + '.' + name + desc + " (" + tag + (itf? " itf": "") + ')';
}
}
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handler.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handler.java
index feafd1075..6279de395 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handler.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handler.java
@@ -31,7 +31,7 @@
/**
* Information about an exception handler block.
- *
+ *
* @author Eric Bruneton
*/
class Handler {
@@ -71,7 +71,7 @@ class Handler {
/**
* Removes the range between start and end from the given exception
* handlers.
- *
+ *
* @param h
* an exception handler list.
* @param start
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Item.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Item.java
index 0404810ec..0119a0641 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Item.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Item.java
@@ -32,7 +32,7 @@
/**
* A constant pool item. Constant pool items can be created with the 'newXXX'
* methods in the {@link ClassWriter} class.
- *
+ *
* @author Eric Bruneton
*/
final class Item {
@@ -51,12 +51,13 @@ final class Item {
* {@link ClassWriter#STR}, {@link ClassWriter#CLASS},
* {@link ClassWriter#NAME_TYPE}, {@link ClassWriter#FIELD},
* {@link ClassWriter#METH}, {@link ClassWriter#IMETH},
+ * {@link ClassWriter#MODULE}, {@link ClassWriter#PACKAGE},
* {@link ClassWriter#MTYPE}, {@link ClassWriter#INDY}.
- *
+ *
* MethodHandle constant 9 variations are stored using a range of 9 values
* from {@link ClassWriter#HANDLE_BASE} + 1 to
* {@link ClassWriter#HANDLE_BASE} + 9.
- *
+ *
* Special Item types are used for Items that are stored in the ClassWriter
* {@link ClassWriter#typeTable}, instead of the constant pool, in order to
* avoid clashes with normal constant pool items in the ClassWriter constant
@@ -114,7 +115,7 @@ final class Item {
/**
* Constructs an uninitialized {@link Item} for constant pool element at
* given position.
- *
+ *
* @param index
* index of the item to be constructed.
*/
@@ -124,7 +125,7 @@ final class Item {
/**
* Constructs a copy of the given item.
- *
+ *
* @param index
* index of the item to be constructed.
* @param i
@@ -143,7 +144,7 @@ final class Item {
/**
* Sets this item to an integer item.
- *
+ *
* @param intVal
* the value of this item.
*/
@@ -155,7 +156,7 @@ void set(final int intVal) {
/**
* Sets this item to a long item.
- *
+ *
* @param longVal
* the value of this item.
*/
@@ -167,7 +168,7 @@ void set(final long longVal) {
/**
* Sets this item to a float item.
- *
+ *
* @param floatVal
* the value of this item.
*/
@@ -179,7 +180,7 @@ void set(final float floatVal) {
/**
* Sets this item to a double item.
- *
+ *
* @param doubleVal
* the value of this item.
*/
@@ -191,7 +192,7 @@ void set(final double doubleVal) {
/**
* Sets this item to an item that do not hold a primitive value.
- *
+ *
* @param type
* the type of this item.
* @param strVal1
@@ -201,6 +202,7 @@ void set(final double doubleVal) {
* @param strVal3
* third part of the value of this item.
*/
+ @SuppressWarnings("fallthrough")
void set(final int type, final String strVal1, final String strVal2,
final String strVal3) {
this.type = type;
@@ -213,6 +215,8 @@ void set(final int type, final String strVal1, final String strVal2,
case ClassWriter.UTF8:
case ClassWriter.STR:
case ClassWriter.MTYPE:
+ case ClassWriter.MODULE:
+ case ClassWriter.PACKAGE:
case ClassWriter.TYPE_NORMAL:
hashCode = 0x7FFFFFFF & (type + strVal1.hashCode());
return;
@@ -233,7 +237,7 @@ void set(final int type, final String strVal1, final String strVal2,
/**
* Sets the item to an InvokeDynamic item.
- *
+ *
* @param name
* invokedynamic's name.
* @param desc
@@ -252,7 +256,7 @@ void set(String name, String desc, int bsmIndex) {
/**
* Sets the item to a BootstrapMethod item.
- *
+ *
* @param position
* position in byte in the class attribute BootrapMethods.
* @param hashCode
@@ -269,7 +273,7 @@ void set(int position, int hashCode) {
/**
* Indicates if the given item is equal to this one. This method assumes
* that the two items have the same {@link #type}.
- *
+ *
* @param i
* the item to be compared to this one. Both items must have the
* same {@link #type}.
@@ -281,6 +285,8 @@ boolean isEqualTo(final Item i) {
case ClassWriter.UTF8:
case ClassWriter.STR:
case ClassWriter.CLASS:
+ case ClassWriter.MODULE:
+ case ClassWriter.PACKAGE:
case ClassWriter.MTYPE:
case ClassWriter.TYPE_NORMAL:
return i.strVal1.equals(strVal1);
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Label.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Label.java
index 16c51a247..0f84f1d38 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Label.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Label.java
@@ -35,7 +35,7 @@
* designates the instruction that is just after. Note however that there
* can be other elements between a label and the instruction it designates (such
* as other labels, stack map frames, line numbers, etc.).
- *
+ *
* @author Eric Bruneton
*/
public class Label {
@@ -117,7 +117,7 @@ public class Label {
/**
* Flags that indicate the status of this label.
- *
+ *
* @see #DEBUG
* @see #RESOLVED
* @see #RESIZED
@@ -131,7 +131,11 @@ public class Label {
int status;
/**
- * The line number corresponding to this label, if known.
+ * The line number corresponding to this label, if known. If there are
+ * several lines, each line is stored in a separate label, all linked via
+ * their next field (these links are created in ClassReader and removed just
+ * before visitLabel is called, so that this does not impact the rest of the
+ * code).
*/
int line;
@@ -170,7 +174,7 @@ public class Label {
* represented by the Label object that corresponds to the first instruction
* of this basic block. Each node also stores the list of its successors in
* the graph, as a linked list of Edge objects.
- *
+ *
* The control flow analysis algorithms used to compute the maximum stack
* size or the stack map frames are similar and use two steps. The first
* step, during the visit of each instruction, builds information about the
@@ -182,7 +186,7 @@ public class Label {
* information about the input frame of each basic block, from the input
* state of the first basic block (known from the method signature), and by
* the using the previously computed relative output frames.
- *
+ *
* The algorithm used to compute the maximum stack size only computes the
* relative output and absolute input stack heights, while the algorithm
* used to compute stack map frames computes relative output frames and
@@ -192,10 +196,10 @@ public class Label {
/**
* Start of the output stack relatively to the input stack. The exact
* semantics of this field depends on the algorithm that is used.
- *
+ *
* When only the maximum stack size is computed, this field is the number of
* elements in the input stack.
- *
+ *
* When the stack map frames are completely computed, this field is the
* offset of the first output stack element relatively to the top of the
* input stack. This offset is always negative or null. A null offset means
@@ -239,8 +243,9 @@ public class Label {
* The next basic block in the basic block stack. This stack is used in the
* main loop of the fix point algorithm used in the second step of the
* control flow analysis algorithms. It is also used in
- * {@link #visitSubroutine} to avoid using a recursive method.
- *
+ * {@link #visitSubroutine} to avoid using a recursive method, and in
+ * ClassReader to temporarily store multiple source lines for a label.
+ *
* @see MethodWriter#visitMaxs
*/
Label next;
@@ -264,7 +269,7 @@ public Label() {
* from the start of the method's bytecode. This method is intended for
* {@link Attribute} sub classes, and is normally not needed by class
* generators or adapters.
- *
+ *
* @return the offset corresponding to this label.
* @throws IllegalStateException
* if this label is not resolved yet.
@@ -282,7 +287,7 @@ public int getOffset() {
* position of the label is known, the offset is computed and written
* directly. Otherwise, a null offset is written and a new forward reference
* is declared for this label.
- *
+ *
* @param owner
* the code writer that calls this method.
* @param out
@@ -320,7 +325,7 @@ void put(final MethodWriter owner, final ByteVector out, final int source,
* for a true forward reference, i.e. only if this label is not resolved
* yet. For backward references, the offset of the reference can be, and
* must be, computed and stored directly.
- *
+ *
* @param sourcePosition
* the position of the referencing instruction. This position
* will be used to compute the offset of this forward reference.
@@ -348,20 +353,19 @@ private void addReference(final int sourcePosition,
* when this label is added to the bytecode of the method, i.e. when its
* position becomes known. This method fills in the blanks that where left
* in the bytecode by each forward reference previously added to this label.
- *
+ *
* @param owner
* the code writer that calls this method.
* @param position
* the position of this label in the bytecode.
* @param data
* the bytecode of the method.
- * @return true if a blank that was left for this label was to
+ * @return true if a blank that was left for this label was too
* small to store the offset. In such a case the corresponding jump
* instruction is replaced with a pseudo instruction (using unused
* opcodes) using an unsigned two bytes offset. These pseudo
- * instructions will need to be replaced with true instructions with
- * wider offsets (4 bytes instead of 2). This is done in
- * {@link MethodWriter#resizeInstructions}.
+ * instructions will be replaced with standard bytecode instructions
+ * with wider offsets (4 bytes instead of 2), in ClassReader.
* @throws IllegalArgumentException
* if this label has already been resolved, or if it has not
* been created by the given code writer.
@@ -416,11 +420,11 @@ boolean resolve(final MethodWriter owner, final int position,
* isolated label or for the first label in a series of successive labels,
* this method returns the label itself. For other labels it returns the
* first label of the series.
- *
+ *
* @return the first label of the series to which this label belongs.
*/
Label getFirst() {
- return !ClassReader.FRAMES || frame == null ? this : frame.owner;
+ return frame == null ? this : frame.owner;
}
// ------------------------------------------------------------------------
@@ -429,7 +433,7 @@ Label getFirst() {
/**
* Returns true is this basic block belongs to the given subroutine.
- *
+ *
* @param id
* a subroutine id.
* @return true is this basic block belongs to the given subroutine.
@@ -444,7 +448,7 @@ boolean inSubroutine(final long id) {
/**
* Returns true if this basic block and the given one belong to a common
* subroutine.
- *
+ *
* @param block
* another basic block.
* @return true if this basic block and the given one belong to a common
@@ -464,7 +468,7 @@ boolean inSameSubroutine(final Label block) {
/**
* Marks this basic block as belonging to the given subroutine.
- *
+ *
* @param id
* a subroutine id.
* @param nbSubroutines
@@ -483,7 +487,7 @@ void addToSubroutine(final long id, final int nbSubroutines) {
* blocks as belonging to this subroutine. This method follows the control
* flow graph to find all the blocks that are reachable from the current
* block WITHOUT following any JSR target.
- *
+ *
* @param JSR
* a JSR block that jumps to this subroutine. If this JSR is not
* null it is added to the successor of the RET blocks found in
@@ -550,7 +554,7 @@ void visitSubroutine(final Label JSR, final long id, final int nbSubroutines) {
/**
* Returns a string representation of this label.
- *
+ *
* @return a string representation of this label.
*/
@Override
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java
index 0a5d22061..233ae2189 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java
@@ -33,15 +33,16 @@
* A visitor to visit a Java method. The methods of this class must be called in
* the following order: ( visitParameter )* [
* visitAnnotationDefault ] ( visitAnnotation |
- * visitTypeAnnotation | visitAttribute )* [
- * visitCode ( visitFrame | visitXInsn |
- * visitLabel | visitInsnAnnotation |
- * visitTryCatchBlock | visitTryCatchBlockAnnotation |
- * visitLocalVariable | visitLocalVariableAnnotation |
- * visitLineNumber )* visitMaxs ] visitEnd. In
- * addition, the visitXInsn and visitLabel methods must
- * be called in the sequential order of the bytecode instructions of the visited
- * code, visitInsnAnnotation must be called after the annotated
+ * visitParameterAnnotation visitTypeAnnotation |
+ * visitAttribute )* [ visitCode ( visitFrame |
+ * visitXInsn | visitLabel |
+ * visitInsnAnnotation | visitTryCatchBlock |
+ * visitTryCatchAnnotation | visitLocalVariable |
+ * visitLocalVariableAnnotation | visitLineNumber )*
+ * visitMaxs ] visitEnd. In addition, the
+ * visitXInsn and visitLabel methods must be called in
+ * the sequential order of the bytecode instructions of the visited code,
+ * visitInsnAnnotation must be called after the annotated
* instruction, visitTryCatchBlock must be called before the
* labels passed as arguments have been visited,
* visitTryCatchBlockAnnotation must be called after the
@@ -49,14 +50,14 @@
* visitLocalVariable, visitLocalVariableAnnotation and
* visitLineNumber methods must be called after the labels
* passed as arguments have been visited.
- *
+ *
* @author Eric Bruneton
*/
public abstract class MethodVisitor {
/**
* The ASM API version implemented by this visitor. The value of this field
- * must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
+ * must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
*/
protected final int api;
@@ -68,10 +69,10 @@ public abstract class MethodVisitor {
/**
* Constructs a new {@link MethodVisitor}.
- *
+ *
* @param api
* the ASM API version implemented by this visitor. Must be one
- * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
+ * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
*/
public MethodVisitor(final int api) {
this(api, null);
@@ -79,16 +80,16 @@ public MethodVisitor(final int api) {
/**
* Constructs a new {@link MethodVisitor}.
- *
+ *
* @param api
* the ASM API version implemented by this visitor. Must be one
- * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
+ * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
* @param mv
* the method visitor to which this visitor must delegate method
* calls. May be null.
*/
public MethodVisitor(final int api, final MethodVisitor mv) {
- if (api != Opcodes.ASM4 && api != Opcodes.ASM5) {
+ if (api < Opcodes.ASM4 || api > Opcodes.ASM6) {
throw new IllegalArgumentException();
}
this.api = api;
@@ -101,7 +102,7 @@ public MethodVisitor(final int api, final MethodVisitor mv) {
/**
* Visits a parameter of this method.
- *
+ *
* @param name
* parameter name or null if none is provided.
* @param access
@@ -120,7 +121,7 @@ public void visitParameter(String name, int access) {
/**
* Visits the default value of this annotation interface method.
- *
+ *
* @return a visitor to the visit the actual default value of this
* annotation interface method, or null if this visitor is
* not interested in visiting this default value. The 'name'
@@ -137,7 +138,7 @@ public AnnotationVisitor visitAnnotationDefault() {
/**
* Visits an annotation of this method.
- *
+ *
* @param desc
* the class descriptor of the annotation class.
* @param visible
@@ -154,7 +155,7 @@ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
/**
* Visits an annotation on a type in the method signature.
- *
+ *
* @param typeRef
* a reference to the annotated type. The sort of this type
* reference must be {@link TypeReference#METHOD_TYPE_PARAMETER
@@ -190,7 +191,7 @@ public AnnotationVisitor visitTypeAnnotation(int typeRef,
/**
* Visits an annotation of a parameter this method.
- *
+ *
* @param parameter
* the parameter index.
* @param desc
@@ -210,7 +211,7 @@ public AnnotationVisitor visitParameterAnnotation(int parameter,
/**
* Visits a non standard attribute of this method.
- *
+ *
* @param attr
* an attribute.
*/
@@ -271,7 +272,7 @@ public void visitCode() {
* and access flags, is implicit and must not be visited. Also, it is
* illegal to visit two or more frames for the same code location (i.e., at
* least one instruction must be visited between two calls to visitFrame).
- *
+ *
* @param type
* the type of this stack map frame. Must be
* {@link Opcodes#F_NEW} for expanded frames, or
@@ -317,7 +318,7 @@ public void visitFrame(int type, int nLocal, Object[] local, int nStack,
/**
* Visits a zero operand instruction.
- *
+ *
* @param opcode
* the opcode of the instruction to be visited. This opcode is
* either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1,
@@ -343,7 +344,7 @@ public void visitInsn(int opcode) {
/**
* Visits an instruction with a single int operand.
- *
+ *
* @param opcode
* the opcode of the instruction to be visited. This opcode is
* either BIPUSH, SIPUSH or NEWARRAY.
@@ -368,7 +369,7 @@ public void visitIntInsn(int opcode, int operand) {
/**
* Visits a local variable instruction. A local variable instruction is an
* instruction that loads or stores the value of a local variable.
- *
+ *
* @param opcode
* the opcode of the local variable instruction to be visited.
* This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD,
@@ -386,7 +387,7 @@ public void visitVarInsn(int opcode, int var) {
/**
* Visits a type instruction. A type instruction is an instruction that
* takes the internal name of a class as parameter.
- *
+ *
* @param opcode
* the opcode of the type instruction to be visited. This opcode
* is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.
@@ -404,7 +405,7 @@ public void visitTypeInsn(int opcode, String type) {
/**
* Visits a field instruction. A field instruction is an instruction that
* loads or stores the value of a field of an object.
- *
+ *
* @param opcode
* the opcode of the type instruction to be visited. This opcode
* is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
@@ -426,7 +427,7 @@ public void visitFieldInsn(int opcode, String owner, String name,
/**
* Visits a method instruction. A method instruction is an instruction that
* invokes a method.
- *
+ *
* @param opcode
* the opcode of the type instruction to be visited. This opcode
* is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
@@ -455,7 +456,7 @@ public void visitMethodInsn(int opcode, String owner, String name,
/**
* Visits a method instruction. A method instruction is an instruction that
* invokes a method.
- *
+ *
* @param opcode
* the opcode of the type instruction to be visited. This opcode
* is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
@@ -487,7 +488,7 @@ public void visitMethodInsn(int opcode, String owner, String name,
/**
* Visits an invokedynamic instruction.
- *
+ *
* @param name
* the method's name.
* @param desc
@@ -511,7 +512,7 @@ public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
/**
* Visits a jump instruction. A jump instruction is an instruction that may
* jump to another instruction.
- *
+ *
* @param opcode
* the opcode of the type instruction to be visited. This opcode
* is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ,
@@ -531,7 +532,7 @@ public void visitJumpInsn(int opcode, Label label) {
/**
* Visits a label. A label designates the instruction that will be visited
* just after it.
- *
+ *
* @param label
* a {@link Label Label} object.
*/
@@ -550,7 +551,7 @@ public void visitLabel(Label label) {
* future versions of the Java Virtual Machine. To easily detect new
* constant types, implementations of this method should check for
* unexpected constant types, like this:
- *
+ *
*
* if (cst instanceof Integer) {
* // ...
@@ -579,7 +580,7 @@ public void visitLabel(Label label) {
* // throw an exception
* }
*
- *
+ *
* @param cst
* the constant to be loaded on the stack. This parameter must be
* a non null {@link Integer}, a {@link Float}, a {@link Long}, a
@@ -597,7 +598,7 @@ public void visitLdcInsn(Object cst) {
/**
* Visits an IINC instruction.
- *
+ *
* @param var
* index of the local variable to be incremented.
* @param increment
@@ -611,7 +612,7 @@ public void visitIincInsn(int var, int increment) {
/**
* Visits a TABLESWITCH instruction.
- *
+ *
* @param min
* the minimum key value.
* @param max
@@ -631,7 +632,7 @@ public void visitTableSwitchInsn(int min, int max, Label dflt,
/**
* Visits a LOOKUPSWITCH instruction.
- *
+ *
* @param dflt
* beginning of the default handler block.
* @param keys
@@ -648,7 +649,7 @@ public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
/**
* Visits a MULTIANEWARRAY instruction.
- *
+ *
* @param desc
* an array type descriptor (see {@link Type Type}).
* @param dims
@@ -664,7 +665,7 @@ public void visitMultiANewArrayInsn(String desc, int dims) {
* Visits an annotation on an instruction. This method must be called just
* after the annotated instruction. It can be called several times
* for the same instruction.
- *
+ *
* @param typeRef
* a reference to the annotated type. The sort of this type
* reference must be {@link TypeReference#INSTANCEOF INSTANCEOF},
@@ -708,7 +709,7 @@ public AnnotationVisitor visitInsnAnnotation(int typeRef,
/**
* Visits a try catch block.
- *
+ *
* @param start
* beginning of the exception handler's scope (inclusive).
* @param end
@@ -735,7 +736,7 @@ public void visitTryCatchBlock(Label start, Label end, Label handler,
* called after the {@link #visitTryCatchBlock} for the annotated
* exception handler. It can be called several times for the same exception
* handler.
- *
+ *
* @param typeRef
* a reference to the annotated type. The sort of this type
* reference must be {@link TypeReference#EXCEPTION_PARAMETER
@@ -764,7 +765,7 @@ public AnnotationVisitor visitTryCatchAnnotation(int typeRef,
/**
* Visits a local variable declaration.
- *
+ *
* @param name
* the name of a local variable.
* @param desc
@@ -794,7 +795,7 @@ public void visitLocalVariable(String name, String desc, String signature,
/**
* Visits an annotation on a local variable type.
- *
+ *
* @param typeRef
* a reference to the annotated type. The sort of this type
* reference must be {@link TypeReference#LOCAL_VARIABLE
@@ -836,7 +837,7 @@ public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
/**
* Visits a line number declaration.
- *
+ *
* @param line
* a line number. This number refers to the source file from
* which the class was compiled.
@@ -855,7 +856,7 @@ public void visitLineNumber(int line, Label start) {
/**
* Visits the maximum stack size and the maximum number of local variables
* of the method.
- *
+ *
* @param maxStack
* maximum stack size of the method.
* @param maxLocals
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodWriter.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodWriter.java
index 5355b3f05..bf6624ce5 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodWriter.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodWriter.java
@@ -33,7 +33,7 @@
* A {@link MethodVisitor} that generates methods in bytecode form. Each visit
* method of this class appends the bytecode corresponding to the visited
* instruction to a byte vector, in the order these methods are called.
- *
+ *
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
@@ -96,25 +96,37 @@ class MethodWriter extends MethodVisitor {
* Indicates that the stack map frames must be recomputed from scratch. In
* this case the maximum stack size and number of local variables is also
* recomputed from scratch.
- *
+ *
+ * @see #compute
+ */
+ static final int FRAMES = 0;
+
+ /**
+ * Indicates that the stack map frames of type F_INSERT must be computed.
+ * The other frames are not (re)computed. They should all be of type F_NEW
+ * and should be sufficient to compute the content of the F_INSERT frames,
+ * together with the bytecode instructions between a F_NEW and a F_INSERT
+ * frame - and without any knowledge of the type hierarchy (by definition of
+ * F_INSERT).
+ *
* @see #compute
*/
- private static final int FRAMES = 0;
+ static final int INSERTED_FRAMES = 1;
/**
* Indicates that the maximum stack size and number of local variables must
* be automatically computed.
- *
+ *
* @see #compute
*/
- private static final int MAXS = 1;
+ static final int MAXS = 2;
/**
* Indicates that nothing must be automatically computed.
- *
+ *
* @see #compute
*/
- private static final int NOTHING = 2;
+ static final int NOTHING = 3;
/**
* The class writer to which this method must be added.
@@ -248,7 +260,7 @@ class MethodWriter extends MethodVisitor {
/**
* Number of stack map frames in the StackMapTable attribute.
*/
- private int frameCount;
+ int frameCount;
/**
* The StackMapTable attribute.
@@ -263,7 +275,7 @@ class MethodWriter extends MethodVisitor {
/**
* The last frame that was written in the StackMapTable attribute.
- *
+ *
* @see #frame
*/
private int[] previousFrame;
@@ -354,11 +366,6 @@ class MethodWriter extends MethodVisitor {
*/
private Attribute cattrs;
- /**
- * Indicates if some jump instructions are too small and need to be resized.
- */
- private boolean resize;
-
/**
* The number of subroutines in this method.
*/
@@ -378,8 +385,9 @@ class MethodWriter extends MethodVisitor {
/**
* Indicates what must be automatically computed.
- *
+ *
* @see #FRAMES
+ * @see #INSERTED_FRAMES
* @see #MAXS
* @see #NOTHING
*/
@@ -428,7 +436,7 @@ class MethodWriter extends MethodVisitor {
/**
* Constructs a new {@link MethodWriter}.
- *
+ *
* @param cw
* the class writer in which the method must be added.
* @param access
@@ -442,18 +450,13 @@ class MethodWriter extends MethodVisitor {
* @param exceptions
* the internal names of the method's exceptions. May be
* null.
- * @param computeMaxs
- * true if the maximum stack size and number of local
- * variables must be automatically computed.
- * @param computeFrames
- * true if the stack map tables must be recomputed from
- * scratch.
+ * @param compute
+ * Indicates what must be automatically computed (see #compute).
*/
MethodWriter(final ClassWriter cw, final int access, final String name,
final String desc, final String signature,
- final String[] exceptions, final boolean computeMaxs,
- final boolean computeFrames) {
- super(Opcodes.ASM5);
+ final String[] exceptions, final int compute) {
+ super(Opcodes.ASM6);
if (cw.firstMethod == null) {
cw.firstMethod = this;
} else {
@@ -468,9 +471,7 @@ class MethodWriter extends MethodVisitor {
this.name = cw.newUTF8(name);
this.desc = cw.newUTF8(desc);
this.descriptor = desc;
- if (ClassReader.SIGNATURES) {
- this.signature = signature;
- }
+ this.signature = signature;
if (exceptions != null && exceptions.length > 0) {
exceptionCount = exceptions.length;
this.exceptions = new int[exceptionCount];
@@ -478,8 +479,8 @@ class MethodWriter extends MethodVisitor {
this.exceptions[i] = cw.newClass(exceptions[i]);
}
}
- this.compute = computeFrames ? FRAMES : (computeMaxs ? MAXS : NOTHING);
- if (computeMaxs || computeFrames) {
+ this.compute = compute;
+ if (compute != NOTHING) {
// updates maxLocals
int size = Type.getArgumentsAndReturnSizes(descriptor) >> 2;
if ((access & Opcodes.ACC_STATIC) != 0) {
@@ -510,9 +511,6 @@ public void visitParameter(String name, int access) {
@Override
public AnnotationVisitor visitAnnotationDefault() {
- if (!ClassReader.ANNOTATIONS) {
- return null;
- }
annd = new ByteVector();
return new AnnotationWriter(cw, false, annd, null, 0);
}
@@ -520,9 +518,6 @@ public AnnotationVisitor visitAnnotationDefault() {
@Override
public AnnotationVisitor visitAnnotation(final String desc,
final boolean visible) {
- if (!ClassReader.ANNOTATIONS) {
- return null;
- }
ByteVector bv = new ByteVector();
// write type, and reserve space for values count
bv.putShort(cw.newUTF8(desc)).putShort(0);
@@ -540,9 +535,6 @@ public AnnotationVisitor visitAnnotation(final String desc,
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
final TypePath typePath, final String desc, final boolean visible) {
- if (!ClassReader.ANNOTATIONS) {
- return null;
- }
ByteVector bv = new ByteVector();
// write target_type and target_info
AnnotationWriter.putTarget(typeRef, typePath, bv);
@@ -563,9 +555,6 @@ public AnnotationVisitor visitTypeAnnotation(final int typeRef,
@Override
public AnnotationVisitor visitParameterAnnotation(final int parameter,
final String desc, final boolean visible) {
- if (!ClassReader.ANNOTATIONS) {
- return null;
- }
ByteVector bv = new ByteVector();
if ("Ljava/lang/Synthetic;".equals(desc)) {
// workaround for a bug in javac with synthetic parameters
@@ -610,11 +599,33 @@ public void visitCode() {
@Override
public void visitFrame(final int type, final int nLocal,
final Object[] local, final int nStack, final Object[] stack) {
- if (!ClassReader.FRAMES || compute == FRAMES) {
+ if (compute == FRAMES) {
return;
}
- if (type == Opcodes.F_NEW) {
+ if (compute == INSERTED_FRAMES) {
+ if (currentBlock.frame == null) {
+ // This should happen only once, for the implicit first frame
+ // (which is explicitly visited in ClassReader if the
+ // EXPAND_ASM_INSNS option is used).
+ currentBlock.frame = new CurrentFrame();
+ currentBlock.frame.owner = currentBlock;
+ currentBlock.frame.initInputFrame(cw, access,
+ Type.getArgumentTypes(descriptor), nLocal);
+ visitImplicitFirstFrame();
+ } else {
+ if (type == Opcodes.F_NEW) {
+ currentBlock.frame.set(cw, nLocal, local, nStack, stack);
+ } else {
+ // In this case type is equal to F_INSERT by hypothesis, and
+ // currentBlock.frame contains the stack map frame at the
+ // current instruction, computed from the last F_NEW frame
+ // and the bytecode instructions in between (via calls to
+ // CurrentFrame#execute).
+ }
+ visitFrame(currentBlock.frame);
+ }
+ } else if (type == Opcodes.F_NEW) {
if (previousFrame == null) {
visitImplicitFirstFrame();
}
@@ -622,10 +633,10 @@ public void visitFrame(final int type, final int nLocal,
int frameIndex = startFrame(code.length, nLocal, nStack);
for (int i = 0; i < nLocal; ++i) {
if (local[i] instanceof String) {
- frame[frameIndex++] = Frame.OBJECT
- | cw.addType((String) local[i]);
+ String desc = Type.getObjectType((String) local[i]).getDescriptor();
+ frame[frameIndex++] = Frame.type(cw, desc);
} else if (local[i] instanceof Integer) {
- frame[frameIndex++] = ((Integer) local[i]).intValue();
+ frame[frameIndex++] = Frame.BASE | ((Integer) local[i]).intValue();
} else {
frame[frameIndex++] = Frame.UNINITIALIZED
| cw.addUninitializedType("",
@@ -634,10 +645,10 @@ public void visitFrame(final int type, final int nLocal,
}
for (int i = 0; i < nStack; ++i) {
if (stack[i] instanceof String) {
- frame[frameIndex++] = Frame.OBJECT
- | cw.addType((String) stack[i]);
+ String desc = Type.getObjectType((String) stack[i]).getDescriptor();
+ frame[frameIndex++] = Frame.type(cw, desc);
} else if (stack[i] instanceof Integer) {
- frame[frameIndex++] = ((Integer) stack[i]).intValue();
+ frame[frameIndex++] = Frame.BASE | ((Integer) stack[i]).intValue();
} else {
frame[frameIndex++] = Frame.UNINITIALIZED
| cw.addUninitializedType("",
@@ -718,7 +729,7 @@ public void visitInsn(final int opcode) {
// update currentBlock
// Label currentBlock = this.currentBlock;
if (currentBlock != null) {
- if (compute == FRAMES) {
+ if (compute == FRAMES || compute == INSERTED_FRAMES) {
currentBlock.frame.execute(opcode, 0, null, null);
} else {
// updates current and max stack sizes
@@ -741,7 +752,7 @@ public void visitIntInsn(final int opcode, final int operand) {
lastCodeOffset = code.length;
// Label currentBlock = this.currentBlock;
if (currentBlock != null) {
- if (compute == FRAMES) {
+ if (compute == FRAMES || compute == INSERTED_FRAMES) {
currentBlock.frame.execute(opcode, operand, null, null);
} else if (opcode != Opcodes.NEWARRAY) {
// updates current and max stack sizes only for NEWARRAY
@@ -766,7 +777,7 @@ public void visitVarInsn(final int opcode, final int var) {
lastCodeOffset = code.length;
// Label currentBlock = this.currentBlock;
if (currentBlock != null) {
- if (compute == FRAMES) {
+ if (compute == FRAMES || compute == INSERTED_FRAMES) {
currentBlock.frame.execute(opcode, var, null, null);
} else {
// updates current and max stack sizes
@@ -823,10 +834,10 @@ public void visitVarInsn(final int opcode, final int var) {
@Override
public void visitTypeInsn(final int opcode, final String type) {
lastCodeOffset = code.length;
- Item i = cw.newClassItem(type);
+ Item i = cw.newStringishItem(ClassWriter.CLASS, type);
// Label currentBlock = this.currentBlock;
if (currentBlock != null) {
- if (compute == FRAMES) {
+ if (compute == FRAMES || compute == INSERTED_FRAMES) {
currentBlock.frame.execute(opcode, code.length, cw, i);
} else if (opcode == Opcodes.NEW) {
// updates current and max stack sizes only if opcode == NEW
@@ -849,7 +860,7 @@ public void visitFieldInsn(final int opcode, final String owner,
Item i = cw.newFieldItem(owner, name, desc);
// Label currentBlock = this.currentBlock;
if (currentBlock != null) {
- if (compute == FRAMES) {
+ if (compute == FRAMES || compute == INSERTED_FRAMES) {
currentBlock.frame.execute(opcode, 0, cw, i);
} else {
int size;
@@ -889,7 +900,7 @@ public void visitMethodInsn(final int opcode, final String owner,
int argSize = i.intVal;
// Label currentBlock = this.currentBlock;
if (currentBlock != null) {
- if (compute == FRAMES) {
+ if (compute == FRAMES || compute == INSERTED_FRAMES) {
currentBlock.frame.execute(opcode, 0, cw, i);
} else {
/*
@@ -941,7 +952,7 @@ public void visitInvokeDynamicInsn(final String name, final String desc,
int argSize = i.intVal;
// Label currentBlock = this.currentBlock;
if (currentBlock != null) {
- if (compute == FRAMES) {
+ if (compute == FRAMES || compute == INSERTED_FRAMES) {
currentBlock.frame.execute(Opcodes.INVOKEDYNAMIC, 0, cw, i);
} else {
/*
@@ -975,7 +986,9 @@ public void visitInvokeDynamicInsn(final String name, final String desc,
}
@Override
- public void visitJumpInsn(final int opcode, final Label label) {
+ public void visitJumpInsn(int opcode, final Label label) {
+ boolean isWide = opcode >= 200; // GOTO_W
+ opcode = isWide ? opcode - 33 : opcode;
lastCodeOffset = code.length;
Label nextInsn = null;
// Label currentBlock = this.currentBlock;
@@ -990,6 +1003,8 @@ public void visitJumpInsn(final int opcode, final Label label) {
// creates a Label for the next basic block
nextInsn = new Label();
}
+ } else if (compute == INSERTED_FRAMES) {
+ currentBlock.frame.execute(opcode, 0, null, null);
} else {
if (opcode == Opcodes.JSR) {
if ((label.status & Label.SUBROUTINE) == 0) {
@@ -1021,8 +1036,8 @@ public void visitJumpInsn(final int opcode, final Label label) {
/*
* case of a backward jump with an offset < -32768. In this case we
* automatically replace GOTO with GOTO_W, JSR with JSR_W and IFxxx
- *
- * This method must be called after all the method that is being built
- * has been visited. In particular, the {@link Label Label} objects used
- * to construct the method are no longer valid after this method has been
- * called.
- */
- private void resizeInstructions() {
- byte[] b = code.data; // bytecode of the method
- int u, v, label; // indexes in b
- int i, j; // loop indexes
- /*
- * 1st step: As explained above, resizing an instruction may require to
- * resize another one, which may require to resize yet another one, and
- * so on. The first step of the algorithm consists in finding all the
- * instructions that need to be resized, without modifying the code.
- * This is done by the following "fix point" algorithm:
- *
- * Parse the code to find the jump instructions whose offset will need
- * more than 2 bytes to be stored (the future offset is computed from
- * the current offset and from the number of bytes that will be inserted
- * or removed between the source and target instructions). For each such
- * instruction, adds an entry in (a copy of) the indexes and sizes
- * arrays (if this has not already been done in a previous iteration!).
- *
- * If at least one entry has been added during the previous step, go
- * back to the beginning, otherwise stop.
- *
- * In fact the real algorithm is complicated by the fact that the size
- * of TABLESWITCH and LOOKUPSWITCH instructions depends on their
- * position in the bytecode (because of padding). In order to ensure the
- * convergence of the algorithm, the number of bytes to be added or
- * removed from these instructions is over estimated during the previous
- * loop, and computed exactly only after the loop is finished (this
- * requires another pass to parse the bytecode of the method).
- */
- int[] allIndexes = new int[0]; // copy of indexes
- int[] allSizes = new int[0]; // copy of sizes
- boolean[] resize; // instructions to be resized
- int newOffset; // future offset of a jump instruction
-
- resize = new boolean[code.length];
-
- // 3 = loop again, 2 = loop ended, 1 = last pass, 0 = done
- int state = 3;
- do {
- if (state == 3) {
- state = 2;
- }
- u = 0;
- while (u < b.length) {
- int opcode = b[u] & 0xFF; // opcode of current instruction
- int insert = 0; // bytes to be added after this instruction
-
- switch (ClassWriter.TYPE[opcode]) {
- case ClassWriter.NOARG_INSN:
- case ClassWriter.IMPLVAR_INSN:
- u += 1;
- break;
- case ClassWriter.LABEL_INSN:
- if (opcode > 201) {
- // converts temporary opcodes 202 to 217, 218 and
- // 219 to IFEQ ... JSR (inclusive), IFNULL and
- // IFNONNULL
- opcode = opcode < 218 ? opcode - 49 : opcode - 20;
- label = u + readUnsignedShort(b, u + 1);
- } else {
- label = u + readShort(b, u + 1);
- }
- newOffset = getNewOffset(allIndexes, allSizes, u, label);
- if (newOffset < Short.MIN_VALUE
- || newOffset > Short.MAX_VALUE) {
- if (!resize[u]) {
- if (opcode == Opcodes.GOTO || opcode == Opcodes.JSR) {
- // two additional bytes will be required to
- // replace this GOTO or JSR instruction with
- // a GOTO_W or a JSR_W
- insert = 2;
- } else {
- // five additional bytes will be required to
- // replace this IFxxx
- * Note: it is possible to have several entries for the same instruction in
- * the indexes and sizes: two entries (index=a,size=b) and
- * (index=a,size=b') are equivalent to a single entry (index=a,size=b+b').
- *
- * @param indexes
- * current positions of the instructions to be resized. Each
- * instruction must be designated by the index of its last
- * byte, plus one (or, in other words, by the index of the
- * first byte of the next instruction).
- * @param sizes
- * the number of bytes to be added to the above
- * instructions. More precisely, for each i < len,
- * sizes[i] bytes will be added at the end of the
- * instruction designated by indexes[i] or, if
- * sizes[i] is negative, the last |
- * sizes[i]| bytes of the instruction will be removed
- * (the instruction size must not become negative or
- * null).
- * @param begin
- * index of the first byte of the source instruction.
- * @param end
- * index of the first byte of the target instruction.
- * @return the future value of the given bytecode offset.
- */
- static int getNewOffset(final int[] indexes, final int[] sizes,
- final int begin, final int end) {
- int offset = end - begin;
- for (int i = 0; i < indexes.length; ++i) {
- if (begin < indexes[i] && indexes[i] <= end) {
- // forward jump
- offset += sizes[i];
- } else if (end < indexes[i] && indexes[i] <= begin) {
- // backward jump
- offset -= sizes[i];
- }
- }
- return offset;
- }
-
- /**
- * Updates the offset of the given label.
- *
- * @param indexes
- * current positions of the instructions to be resized. Each
- * instruction must be designated by the index of its last
- * byte, plus one (or, in other words, by the index of the
- * first byte of the next instruction).
- * @param sizes
- * the number of bytes to be added to the above
- * instructions. More precisely, for each i < len,
- * sizes[i] bytes will be added at the end of the
- * instruction designated by indexes[i] or, if
- * sizes[i] is negative, the last |
- * sizes[i]| bytes of the instruction will be removed
- * (the instruction size must not become negative or
- * null).
- * @param label
- * the label whose offset must be updated.
- */
- static void getNewOffset(final int[] indexes, final int[] sizes,
- final Label label) {
- if ((label.status & Label.RESIZED) == 0) {
- label.position = getNewOffset(indexes, sizes, 0, label.position);
- label.status |= Label.RESIZED;
- }
- }
}
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java
new file mode 100644
index 000000000..670e61b9c
--- /dev/null
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java
@@ -0,0 +1,190 @@
+/***
+ * 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 jersey.repackaged.org.objectweb.asm;
+
+/**
+ * A visitor to visit a Java module. The methods of this class must be called in
+ * the following order: visitMainClass | ( visitPackage |
+ * visitRequire | visitExport | visitOpen |
+ * visitUse | visitProvide )* visitEnd.
+ *
+ * The methods {@link #visitRequire(String, int, String)}, {@link #visitExport(String, int, String...)},
+ * {@link #visitOpen(String, int, String...)} and {@link #visitPackage(String)}
+ * take as parameter a package name or a module name. Unlike the other names which are internal names
+ * (names separated by slash), module and package names are qualified names (names separated by dot).
+ *
+ * @author Remi Forax
+ */
+public abstract class ModuleVisitor {
+ /**
+ * The ASM API version implemented by this visitor. The value of this field
+ * must be {@link Opcodes#ASM6}.
+ */
+ protected final int api;
+
+ /**
+ * The module visitor to which this visitor must delegate method calls. May
+ * be null.
+ */
+ protected ModuleVisitor mv;
+
+ /**
+ * Constructs a new {@link ModuleVisitor}.
+ *
+ * @param api
+ * the ASM API version implemented by this visitor. Must be {@link Opcodes#ASM6}.
+ */
+ public ModuleVisitor(final int api) {
+ this(api, null);
+ }
+
+ /**
+ * Constructs a new {@link ModuleVisitor}.
+ *
+ * @param api
+ * the ASM API version implemented by this visitor. Must be {@link Opcodes#ASM6}.
+ * @param mv
+ * the module visitor to which this visitor must delegate method
+ * calls. May be null.
+ */
+ public ModuleVisitor(final int api, final ModuleVisitor mv) {
+ if (api != Opcodes.ASM6) {
+ throw new IllegalArgumentException();
+ }
+ this.api = api;
+ this.mv = mv;
+ }
+
+ /**
+ * Visit the main class of the current module.
+ *
+ * @param mainClass the internal name of the main class of the current module.
+ */
+ public void visitMainClass(String mainClass) {
+ if (mv != null) {
+ mv.visitMainClass(mainClass);
+ }
+ }
+
+ /**
+ * Visit a package of the current module.
+ *
+ * @param packaze the qualified name of a package.
+ */
+ public void visitPackage(String packaze) {
+ if (mv != null) {
+ mv.visitPackage(packaze);
+ }
+ }
+
+ /**
+ * Visits a dependence of the current module.
+ *
+ * @param module the qualified name of the dependence.
+ * @param access the access flag of the dependence among
+ * ACC_TRANSITIVE, ACC_STATIC_PHASE, ACC_SYNTHETIC
+ * and ACC_MANDATED.
+ * @param version the module version at compile time or null.
+ */
+ public void visitRequire(String module, int access, String version) {
+ if (mv != null) {
+ mv.visitRequire(module, access, version);
+ }
+ }
+
+ /**
+ * Visit an exported package of the current module.
+ *
+ * @param packaze the qualified name of the exported package.
+ * @param access the access flag of the exported package,
+ * valid values are among {@code ACC_SYNTHETIC} and
+ * {@code ACC_MANDATED}.
+ * @param modules the qualified names of the modules that can access to
+ * the public classes of the exported package or
+ * null.
+ */
+ public void visitExport(String packaze, int access, String... modules) {
+ if (mv != null) {
+ mv.visitExport(packaze, access, modules);
+ }
+ }
+
+ /**
+ * Visit an open package of the current module.
+ *
+ * @param packaze the qualified name of the opened package.
+ * @param access the access flag of the opened package,
+ * valid values are among {@code ACC_SYNTHETIC} and
+ * {@code ACC_MANDATED}.
+ * @param modules the qualified names of the modules that can use deep
+ * reflection to the classes of the open package or
+ * null.
+ */
+ public void visitOpen(String packaze, int access, String... modules) {
+ if (mv != null) {
+ mv.visitOpen(packaze, access, modules);
+ }
+ }
+
+ /**
+ * Visit a service used by the current module.
+ * The name must be the internal name of an interface or a class.
+ *
+ * @param service the internal name of the service.
+ */
+ public void visitUse(String service) {
+ if (mv != null) {
+ mv.visitUse(service);
+ }
+ }
+
+ /**
+ * Visit an implementation of a service.
+ *
+ * @param service the internal name of the service
+ * @param providers the internal names of the implementations
+ * of the service (there is at least one provider).
+ */
+ public void visitProvide(String service, String... providers) {
+ if (mv != null) {
+ mv.visitProvide(service, providers);
+ }
+ }
+
+ /**
+ * Visits the end of the module. This method, which is the last one to be
+ * called, is used to inform the visitor that everything have been visited.
+ */
+ public void visitEnd() {
+ if (mv != null) {
+ mv.visitEnd();
+ }
+ }
+}
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleWriter.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleWriter.java
new file mode 100644
index 000000000..0c38c4bda
--- /dev/null
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleWriter.java
@@ -0,0 +1,293 @@
+/***
+ * 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 jersey.repackaged.org.objectweb.asm;
+
+/**
+ * @author Remi Forax
+ */
+final class ModuleWriter extends ModuleVisitor {
+ /**
+ * The class writer to which this Module attribute must be added.
+ */
+ private final ClassWriter cw;
+
+ /**
+ * size in byte of the Module attribute.
+ */
+ int size;
+
+ /**
+ * Number of attributes associated with the current module
+ * (Version, ConcealPackages, etc)
+ */
+ int attributeCount;
+
+ /**
+ * Size in bytes of the attributes associated with the current module
+ */
+ int attributesSize;
+
+ /**
+ * module name index in the constant pool
+ */
+ private final int name;
+
+ /**
+ * module access flags
+ */
+ private final int access;
+
+ /**
+ * module version index in the constant pool or 0
+ */
+ private final int version;
+
+ /**
+ * module main class index in the constant pool or 0
+ */
+ private int mainClass;
+
+ /**
+ * number of packages
+ */
+ private int packageCount;
+
+ /**
+ * The packages in bytecode form. This byte vector only contains
+ * the items themselves, the number of items is store in packageCount
+ */
+ private ByteVector packages;
+
+ /**
+ * number of requires items
+ */
+ private int requireCount;
+
+ /**
+ * The requires items in bytecode form. This byte vector only contains
+ * the items themselves, the number of items is store in requireCount
+ */
+ private ByteVector requires;
+
+ /**
+ * number of exports items
+ */
+ private int exportCount;
+
+ /**
+ * The exports items in bytecode form. This byte vector only contains
+ * the items themselves, the number of items is store in exportCount
+ */
+ private ByteVector exports;
+
+ /**
+ * number of opens items
+ */
+ private int openCount;
+
+ /**
+ * The opens items in bytecode form. This byte vector only contains
+ * the items themselves, the number of items is store in openCount
+ */
+ private ByteVector opens;
+
+ /**
+ * number of uses items
+ */
+ private int useCount;
+
+ /**
+ * The uses items in bytecode form. This byte vector only contains
+ * the items themselves, the number of items is store in useCount
+ */
+ private ByteVector uses;
+
+ /**
+ * number of provides items
+ */
+ private int provideCount;
+
+ /**
+ * The uses provides in bytecode form. This byte vector only contains
+ * the items themselves, the number of items is store in provideCount
+ */
+ private ByteVector provides;
+
+ ModuleWriter(final ClassWriter cw, final int name,
+ final int access, final int version) {
+ super(Opcodes.ASM6);
+ this.cw = cw;
+ this.size = 16; // name + access + version + 5 counts
+ this.name = name;
+ this.access = access;
+ this.version = version;
+ }
+
+ @Override
+ public void visitMainClass(String mainClass) {
+ if (this.mainClass == 0) { // protect against several calls to visitMainClass
+ cw.newUTF8("ModuleMainClass");
+ attributeCount++;
+ attributesSize += 8;
+ }
+ this.mainClass = cw.newClass(mainClass);
+ }
+
+ @Override
+ public void visitPackage(String packaze) {
+ if (packages == null) {
+ // protect against several calls to visitPackage
+ cw.newUTF8("ModulePackages");
+ packages = new ByteVector();
+ attributeCount++;
+ attributesSize += 8;
+ }
+ packages.putShort(cw.newPackage(packaze));
+ packageCount++;
+ attributesSize += 2;
+ }
+
+ @Override
+ public void visitRequire(String module, int access, String version) {
+ if (requires == null) {
+ requires = new ByteVector();
+ }
+ requires.putShort(cw.newModule(module))
+ .putShort(access)
+ .putShort(version == null? 0: cw.newUTF8(version));
+ requireCount++;
+ size += 6;
+ }
+
+ @Override
+ public void visitExport(String packaze, int access, String... modules) {
+ if (exports == null) {
+ exports = new ByteVector();
+ }
+ exports.putShort(cw.newPackage(packaze)).putShort(access);
+ if (modules == null) {
+ exports.putShort(0);
+ size += 6;
+ } else {
+ exports.putShort(modules.length);
+ for(String module: modules) {
+ exports.putShort(cw.newModule(module));
+ }
+ size += 6 + 2 * modules.length;
+ }
+ exportCount++;
+ }
+
+ @Override
+ public void visitOpen(String packaze, int access, String... modules) {
+ if (opens == null) {
+ opens = new ByteVector();
+ }
+ opens.putShort(cw.newPackage(packaze)).putShort(access);
+ if (modules == null) {
+ opens.putShort(0);
+ size += 6;
+ } else {
+ opens.putShort(modules.length);
+ for(String module: modules) {
+ opens.putShort(cw.newModule(module));
+ }
+ size += 6 + 2 * modules.length;
+ }
+ openCount++;
+ }
+
+ @Override
+ public void visitUse(String service) {
+ if (uses == null) {
+ uses = new ByteVector();
+ }
+ uses.putShort(cw.newClass(service));
+ useCount++;
+ size += 2;
+ }
+
+ @Override
+ public void visitProvide(String service, String... providers) {
+ if (provides == null) {
+ provides = new ByteVector();
+ }
+ provides.putShort(cw.newClass(service));
+ provides.putShort(providers.length);
+ for(String provider: providers) {
+ provides.putShort(cw.newClass(provider));
+ }
+ provideCount++;
+ size += 4 + 2 * providers.length;
+ }
+
+ @Override
+ public void visitEnd() {
+ // empty
+ }
+
+ void putAttributes(ByteVector out) {
+ if (mainClass != 0) {
+ out.putShort(cw.newUTF8("ModuleMainClass")).putInt(2).putShort(mainClass);
+ }
+ if (packages != null) {
+ out.putShort(cw.newUTF8("ModulePackages"))
+ .putInt(2 + 2 * packageCount)
+ .putShort(packageCount)
+ .putByteArray(packages.data, 0, packages.length);
+ }
+ }
+
+ void put(ByteVector out) {
+ out.putInt(size);
+ out.putShort(name).putShort(access).putShort(version);
+ out.putShort(requireCount);
+ if (requires != null) {
+ out.putByteArray(requires.data, 0, requires.length);
+ }
+ out.putShort(exportCount);
+ if (exports != null) {
+ out.putByteArray(exports.data, 0, exports.length);
+ }
+ out.putShort(openCount);
+ if (opens != null) {
+ out.putByteArray(opens.data, 0, opens.length);
+ }
+ out.putShort(useCount);
+ if (uses != null) {
+ out.putByteArray(uses.data, 0, uses.length);
+ }
+ out.putShort(provideCount);
+ if (provides != null) {
+ out.putByteArray(provides.data, 0, provides.length);
+ }
+ }
+}
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java
index 67e8e8d67..9b0722d60 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java
@@ -37,7 +37,7 @@
* opcodes are therefore not defined in this interface. Likewise for LDC,
* automatically replaced by LDC_W or LDC2_W when necessary, WIDE, GOTO_W and
* JSR_W.
- *
+ *
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
@@ -47,6 +47,7 @@ public interface Opcodes {
int ASM4 = 4 << 16 | 0 << 8 | 0;
int ASM5 = 5 << 16 | 0 << 8 | 0;
+ int ASM6 = 6 << 16 | 0 << 8 | 0;
// versions
@@ -58,6 +59,7 @@ public interface Opcodes {
int V1_6 = 0 << 16 | 50;
int V1_7 = 0 << 16 | 51;
int V1_8 = 0 << 16 | 52;
+ int V9 = 0 << 16 | 53;
// access flags
@@ -68,18 +70,23 @@ public interface Opcodes {
int ACC_FINAL = 0x0010; // class, field, method, parameter
int ACC_SUPER = 0x0020; // class
int ACC_SYNCHRONIZED = 0x0020; // method
+ int ACC_OPEN = 0x0020; // module
+ int ACC_TRANSITIVE = 0x0020; // module requires
int ACC_VOLATILE = 0x0040; // field
int ACC_BRIDGE = 0x0040; // method
+ int ACC_STATIC_PHASE = 0x0040; // module requires
int ACC_VARARGS = 0x0080; // method
int ACC_TRANSIENT = 0x0080; // field
int ACC_NATIVE = 0x0100; // method
int ACC_INTERFACE = 0x0200; // class
int ACC_ABSTRACT = 0x0400; // class, method
int ACC_STRICT = 0x0800; // method
- int ACC_SYNTHETIC = 0x1000; // class, field, method, parameter
+ int ACC_SYNTHETIC = 0x1000; // class, field, method, parameter, module *
int ACC_ANNOTATION = 0x2000; // class
int ACC_ENUM = 0x4000; // class(?) field inner
- int ACC_MANDATED = 0x8000; // parameter
+ int ACC_MANDATED = 0x8000; // parameter, module, module *
+ int ACC_MODULE = 0x8000; // class
+
// ASM specific pseudo access flags
@@ -146,13 +153,17 @@ public interface Opcodes {
*/
int F_SAME1 = 4;
- Integer TOP = new Integer(0);
- Integer INTEGER = new Integer(1);
- Integer FLOAT = new Integer(2);
- Integer DOUBLE = new Integer(3);
- Integer LONG = new Integer(4);
- Integer NULL = new Integer(5);
- Integer UNINITIALIZED_THIS = new Integer(6);
+ // Do not try to change the following code to use auto-boxing,
+ // these values are compared by reference and not by value
+ // The constructor of Integer was deprecated in 9
+ // but we are stuck with it by backward compatibility
+ @SuppressWarnings("deprecation") Integer TOP = new Integer(0);
+ @SuppressWarnings("deprecation") Integer INTEGER = new Integer(1);
+ @SuppressWarnings("deprecation") Integer FLOAT = new Integer(2);
+ @SuppressWarnings("deprecation") Integer DOUBLE = new Integer(3);
+ @SuppressWarnings("deprecation") Integer LONG = new Integer(4);
+ @SuppressWarnings("deprecation") Integer NULL = new Integer(5);
+ @SuppressWarnings("deprecation") Integer UNINITIALIZED_THIS = new Integer(6);
// opcodes // visit method (- = idem)
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java
index be809a5af..d60e91d58 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java
@@ -35,7 +35,7 @@
/**
* A Java field or method type. This class can be used to make it easier to
* manipulate type and method descriptors.
- *
+ *
* @author Eric Bruneton
* @author Chris Nokleberg
*/
@@ -189,7 +189,7 @@ public class Type {
/**
* Constructs a reference type.
- *
+ *
* @param sort
* the sort of the reference type to be constructed.
* @param buf
@@ -208,7 +208,7 @@ private Type(final int sort, final char[] buf, final int off, final int len) {
/**
* Returns the Java type corresponding to the given type descriptor.
- *
+ *
* @param typeDescriptor
* a field or method type descriptor.
* @return the Java type corresponding to the given type descriptor.
@@ -219,7 +219,7 @@ public static Type getType(final String typeDescriptor) {
/**
* Returns the Java type corresponding to the given internal name.
- *
+ *
* @param internalName
* an internal name.
* @return the Java type corresponding to the given internal name.
@@ -232,7 +232,7 @@ public static Type getObjectType(final String internalName) {
/**
* Returns the Java type corresponding to the given method descriptor.
* Equivalent to Type.getType(methodDescriptor).
- *
+ *
* @param methodDescriptor
* a method descriptor.
* @return the Java type corresponding to the given method descriptor.
@@ -244,7 +244,7 @@ public static Type getMethodType(final String methodDescriptor) {
/**
* Returns the Java method type corresponding to the given argument and
* return types.
- *
+ *
* @param returnType
* the return type of the method.
* @param argumentTypes
@@ -259,7 +259,7 @@ public static Type getMethodType(final Type returnType,
/**
* Returns the Java type corresponding to the given class.
- *
+ *
* @param c
* a class.
* @return the Java type corresponding to the given class.
@@ -292,7 +292,7 @@ public static Type getType(final Class> c) {
/**
* Returns the Java method type corresponding to the given constructor.
- *
+ *
* @param c
* a {@link Constructor Constructor} object.
* @return the Java method type corresponding to the given constructor.
@@ -303,7 +303,7 @@ public static Type getType(final Constructor> c) {
/**
* Returns the Java method type corresponding to the given method.
- *
+ *
* @param m
* a {@link Method Method} object.
* @return the Java method type corresponding to the given method.
@@ -315,7 +315,7 @@ public static Type getType(final Method m) {
/**
* Returns the Java types corresponding to the argument types of the given
* method descriptor.
- *
+ *
* @param methodDescriptor
* a method descriptor.
* @return the Java types corresponding to the argument types of the given
@@ -351,7 +351,7 @@ public static Type[] getArgumentTypes(final String methodDescriptor) {
/**
* Returns the Java types corresponding to the argument types of the given
* method.
- *
+ *
* @param method
* a method.
* @return the Java types corresponding to the argument types of the given
@@ -369,7 +369,7 @@ public static Type[] getArgumentTypes(final Method method) {
/**
* Returns the Java type corresponding to the return type of the given
* method descriptor.
- *
+ *
* @param methodDescriptor
* a method descriptor.
* @return the Java type corresponding to the return type of the given
@@ -377,13 +377,22 @@ public static Type[] getArgumentTypes(final Method method) {
*/
public static Type getReturnType(final String methodDescriptor) {
char[] buf = methodDescriptor.toCharArray();
- return getType(buf, methodDescriptor.indexOf(')') + 1);
+ int off = 1;
+ while (true) {
+ char car = buf[off++];
+ if (car == ')') {
+ return getType(buf, off);
+ } else if (car == 'L') {
+ while (buf[off++] != ';') {
+ }
+ }
+ }
}
/**
* Returns the Java type corresponding to the return type of the given
* method.
- *
+ *
* @param method
* a method.
* @return the Java type corresponding to the return type of the given
@@ -395,7 +404,7 @@ public static Type getReturnType(final Method method) {
/**
* Computes the size of the arguments and of the return value of a method.
- *
+ *
* @param desc
* the descriptor of a method.
* @return the size of the arguments of the method (plus one for the
@@ -436,7 +445,7 @@ public static int getArgumentsAndReturnSizes(final String desc) {
* Returns the Java type corresponding to the given type descriptor. For
* method descriptors, buf is supposed to contain nothing more than the
* descriptor itself.
- *
+ *
* @param buf
* a buffer containing a type descriptor.
* @param off
@@ -494,7 +503,7 @@ private static Type getType(final char[] buf, final int off) {
/**
* Returns the sort of this Java type.
- *
+ *
* @return {@link #VOID VOID}, {@link #BOOLEAN BOOLEAN}, {@link #CHAR CHAR},
* {@link #BYTE BYTE}, {@link #SHORT SHORT}, {@link #INT INT},
* {@link #FLOAT FLOAT}, {@link #LONG LONG}, {@link #DOUBLE DOUBLE},
@@ -508,7 +517,7 @@ public int getSort() {
/**
* Returns the number of dimensions of this array type. This method should
* only be used for an array type.
- *
+ *
* @return the number of dimensions of this array type.
*/
public int getDimensions() {
@@ -522,7 +531,7 @@ public int getDimensions() {
/**
* Returns the type of the elements of this array type. This method should
* only be used for an array type.
- *
+ *
* @return Returns the type of the elements of this array type.
*/
public Type getElementType() {
@@ -532,7 +541,7 @@ public Type getElementType() {
/**
* Returns the binary name of the class corresponding to this type. This
* method must not be used on method types.
- *
+ *
* @return the binary name of the class corresponding to this type.
*/
public String getClassName() {
@@ -573,7 +582,7 @@ public String getClassName() {
* array type. The internal name of a class is its fully qualified name (as
* returned by Class.getName(), where '.' are replaced by '/'. This method
* should only be used for an object or array type.
- *
+ *
* @return the internal name of the class corresponding to this object type.
*/
public String getInternalName() {
@@ -583,7 +592,7 @@ public String getInternalName() {
/**
* Returns the argument types of methods of this type. This method should
* only be used for method types.
- *
+ *
* @return the argument types of methods of this type.
*/
public Type[] getArgumentTypes() {
@@ -593,7 +602,7 @@ public Type[] getArgumentTypes() {
/**
* Returns the return type of methods of this type. This method should only
* be used for method types.
- *
+ *
* @return the return type of methods of this type.
*/
public Type getReturnType() {
@@ -603,7 +612,7 @@ public Type getReturnType() {
/**
* Returns the size of the arguments and of the return value of methods of
* this type. This method should only be used for method types.
- *
+ *
* @return the size of the arguments (plus one for the implicit this
* argument), argSize, and the size of the return value, retSize,
* packed into a single
@@ -621,11 +630,11 @@ public int getArgumentsAndReturnSizes() {
/**
* Returns the descriptor corresponding to this Java type.
- *
+ *
* @return the descriptor corresponding to this Java type.
*/
public String getDescriptor() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
getDescriptor(buf);
return buf.toString();
}
@@ -633,7 +642,7 @@ public String getDescriptor() {
/**
* Returns the descriptor corresponding to the given argument and return
* types.
- *
+ *
* @param returnType
* the return type of the method.
* @param argumentTypes
@@ -643,7 +652,7 @@ public String getDescriptor() {
*/
public static String getMethodDescriptor(final Type returnType,
final Type... argumentTypes) {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append('(');
for (int i = 0; i < argumentTypes.length; ++i) {
argumentTypes[i].getDescriptor(buf);
@@ -656,11 +665,11 @@ public static String getMethodDescriptor(final Type returnType,
/**
* Appends the descriptor corresponding to this Java type to the given
* string buffer.
- *
+ *
* @param buf
* the string buffer to which the descriptor must be appended.
*/
- private void getDescriptor(final StringBuffer buf) {
+ private void getDescriptor(final StringBuilder buf) {
if (this.buf == null) {
// descriptor is in byte 3 of 'off' for primitive types (buf ==
// null)
@@ -683,7 +692,7 @@ private void getDescriptor(final StringBuffer buf) {
* Returns the internal name of the given class. The internal name of a
* class is its fully qualified name, as returned by Class.getName(), where
* '.' are replaced by '/'.
- *
+ *
* @param c
* an object or array class.
* @return the internal name of the given class.
@@ -694,27 +703,27 @@ public static String getInternalName(final Class> c) {
/**
* Returns the descriptor corresponding to the given Java type.
- *
+ *
* @param c
* an object class, a primitive class or an array class.
* @return the descriptor corresponding to the given class.
*/
public static String getDescriptor(final Class> c) {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
getDescriptor(buf, c);
return buf.toString();
}
/**
* Returns the descriptor corresponding to the given constructor.
- *
+ *
* @param c
* a {@link Constructor Constructor} object.
* @return the descriptor of the given constructor.
*/
public static String getConstructorDescriptor(final Constructor> c) {
Class>[] parameters = c.getParameterTypes();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append('(');
for (int i = 0; i < parameters.length; ++i) {
getDescriptor(buf, parameters[i]);
@@ -724,14 +733,14 @@ public static String getConstructorDescriptor(final Constructor> c) {
/**
* Returns the descriptor corresponding to the given method.
- *
+ *
* @param m
* a {@link Method Method} object.
* @return the descriptor of the given method.
*/
public static String getMethodDescriptor(final Method m) {
Class>[] parameters = m.getParameterTypes();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append('(');
for (int i = 0; i < parameters.length; ++i) {
getDescriptor(buf, parameters[i]);
@@ -743,13 +752,13 @@ public static String getMethodDescriptor(final Method m) {
/**
* Appends the descriptor of the given class to the given string buffer.
- *
+ *
* @param buf
* the string buffer to which the descriptor must be appended.
* @param c
* the class whose descriptor must be computed.
*/
- private static void getDescriptor(final StringBuffer buf, final Class> c) {
+ private static void getDescriptor(final StringBuilder buf, final Class> c) {
Class> d = c;
while (true) {
if (d.isPrimitive()) {
@@ -799,7 +808,7 @@ private static void getDescriptor(final StringBuffer buf, final Class> c) {
/**
* Returns the size of values of this type. This method must not be used for
* method types.
- *
+ *
* @return the size of values of this type, i.e., 2 for long and
* double, 0 for void and 1 otherwise.
*/
@@ -811,7 +820,7 @@ public int getSize() {
/**
* Returns a JVM instruction opcode adapted to this Java type. This method
* must not be used for method types.
- *
+ *
* @param opcode
* a JVM instruction opcode. This opcode must be one of ILOAD,
* ISTORE, IALOAD, IASTORE, IADD, ISUB, IMUL, IDIV, IREM, INEG,
@@ -838,7 +847,7 @@ public int getOpcode(final int opcode) {
/**
* Tests if the given object is equal to this type.
- *
+ *
* @param o
* the object to be compared to this type.
* @return true if the given object is equal to this type.
@@ -870,7 +879,7 @@ public boolean equals(final Object o) {
/**
* Returns a hash code value for this type.
- *
+ *
* @return a hash code value for this type.
*/
@Override
@@ -886,7 +895,7 @@ public int hashCode() {
/**
* Returns a string representation of this type.
- *
+ *
* @return the descriptor of this type.
*/
@Override
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/TypePath.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/TypePath.java
index 033753f01..07dba4789 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/TypePath.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/TypePath.java
@@ -1,193 +1,196 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2013 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package jersey.repackaged.org.objectweb.asm;
-
-/**
- * The path to a type argument, wildcard bound, array element type, or static
- * inner type within an enclosing type.
- *
- * @author Eric Bruneton
- */
-public class TypePath {
-
- /**
- * A type path step that steps into the element type of an array type. See
- * {@link #getStep getStep}.
- */
- public final static int ARRAY_ELEMENT = 0;
-
- /**
- * A type path step that steps into the nested type of a class type. See
- * {@link #getStep getStep}.
- */
- public final static int INNER_TYPE = 1;
-
- /**
- * A type path step that steps into the bound of a wildcard type. See
- * {@link #getStep getStep}.
- */
- public final static int WILDCARD_BOUND = 2;
-
- /**
- * A type path step that steps into a type argument of a generic type. See
- * {@link #getStep getStep}.
- */
- public final static int TYPE_ARGUMENT = 3;
-
- /**
- * The byte array where the path is stored, in Java class file format.
- */
- byte[] b;
-
- /**
- * The offset of the first byte of the type path in 'b'.
- */
- int offset;
-
- /**
- * Creates a new type path.
- *
- * @param b
- * the byte array containing the type path in Java class file
- * format.
- * @param offset
- * the offset of the first byte of the type path in 'b'.
- */
- TypePath(byte[] b, int offset) {
- this.b = b;
- this.offset = offset;
- }
-
- /**
- * Returns the length of this path.
- *
- * @return the length of this path.
- */
- public int getLength() {
- return b[offset];
- }
-
- /**
- * Returns the value of the given step of this path.
- *
- * @param index
- * an index between 0 and {@link #getLength()}, exclusive.
- * @return {@link #ARRAY_ELEMENT ARRAY_ELEMENT}, {@link #INNER_TYPE
- * INNER_TYPE}, {@link #WILDCARD_BOUND WILDCARD_BOUND}, or
- * {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
- */
- public int getStep(int index) {
- return b[offset + 2 * index + 1];
- }
-
- /**
- * Returns the index of the type argument that the given step is stepping
- * into. This method should only be used for steps whose value is
- * {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
- *
- * @param index
- * an index between 0 and {@link #getLength()}, exclusive.
- * @return the index of the type argument that the given step is stepping
- * into.
- */
- public int getStepArgument(int index) {
- return b[offset + 2 * index + 2];
- }
-
- /**
- * Converts a type path in string form, in the format used by
- * {@link #toString()}, into a TypePath object.
- *
- * @param typePath
- * a type path in string form, in the format used by
- * {@link #toString()}. May be null or empty.
- * @return the corresponding TypePath object, or null if the path is empty.
- */
- public static TypePath fromString(final String typePath) {
- if (typePath == null || typePath.length() == 0) {
- return null;
- }
- int n = typePath.length();
- ByteVector out = new ByteVector(n);
- out.putByte(0);
- for (int i = 0; i < n;) {
- char c = typePath.charAt(i++);
- if (c == '[') {
- out.put11(ARRAY_ELEMENT, 0);
- } else if (c == '.') {
- out.put11(INNER_TYPE, 0);
- } else if (c == '*') {
- out.put11(WILDCARD_BOUND, 0);
- } else if (c >= '0' && c <= '9') {
- int typeArg = c - '0';
- while (i < n && (c = typePath.charAt(i)) >= '0' && c <= '9') {
- typeArg = typeArg * 10 + c - '0';
- i += 1;
- }
- out.put11(TYPE_ARGUMENT, typeArg);
- }
- }
- out.data[0] = (byte) (out.length / 2);
- return new TypePath(out.data, 0);
- }
-
- /**
- * Returns a string representation of this type path. {@link #ARRAY_ELEMENT
- * ARRAY_ELEMENT} steps are represented with '[', {@link #INNER_TYPE
- * INNER_TYPE} steps with '.', {@link #WILDCARD_BOUND WILDCARD_BOUND} steps
- * with '*' and {@link #TYPE_ARGUMENT TYPE_ARGUMENT} steps with their type
- * argument index in decimal form.
- */
- @Override
- public String toString() {
- int length = getLength();
- StringBuilder result = new StringBuilder(length * 2);
- for (int i = 0; i < length; ++i) {
- switch (getStep(i)) {
- case ARRAY_ELEMENT:
- result.append('[');
- break;
- case INNER_TYPE:
- result.append('.');
- break;
- case WILDCARD_BOUND:
- result.append('*');
- break;
- case TYPE_ARGUMENT:
- result.append(getStepArgument(i));
- break;
- default:
- result.append('_');
- }
- }
- return result.toString();
- }
-}
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2013 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package jersey.repackaged.org.objectweb.asm;
+
+/**
+ * The path to a type argument, wildcard bound, array element type, or static
+ * inner type within an enclosing type.
+ *
+ * @author Eric Bruneton
+ */
+public class TypePath {
+
+ /**
+ * A type path step that steps into the element type of an array type. See
+ * {@link #getStep getStep}.
+ */
+ public final static int ARRAY_ELEMENT = 0;
+
+ /**
+ * A type path step that steps into the nested type of a class type. See
+ * {@link #getStep getStep}.
+ */
+ public final static int INNER_TYPE = 1;
+
+ /**
+ * A type path step that steps into the bound of a wildcard type. See
+ * {@link #getStep getStep}.
+ */
+ public final static int WILDCARD_BOUND = 2;
+
+ /**
+ * A type path step that steps into a type argument of a generic type. See
+ * {@link #getStep getStep}.
+ */
+ public final static int TYPE_ARGUMENT = 3;
+
+ /**
+ * The byte array where the path is stored, in Java class file format.
+ */
+ byte[] b;
+
+ /**
+ * The offset of the first byte of the type path in 'b'.
+ */
+ int offset;
+
+ /**
+ * Creates a new type path.
+ *
+ * @param b
+ * the byte array containing the type path in Java class file
+ * format.
+ * @param offset
+ * the offset of the first byte of the type path in 'b'.
+ */
+ TypePath(byte[] b, int offset) {
+ this.b = b;
+ this.offset = offset;
+ }
+
+ /**
+ * Returns the length of this path.
+ *
+ * @return the length of this path.
+ */
+ public int getLength() {
+ return b[offset];
+ }
+
+ /**
+ * Returns the value of the given step of this path.
+ *
+ * @param index
+ * an index between 0 and {@link #getLength()}, exclusive.
+ * @return {@link #ARRAY_ELEMENT ARRAY_ELEMENT}, {@link #INNER_TYPE
+ * INNER_TYPE}, {@link #WILDCARD_BOUND WILDCARD_BOUND}, or
+ * {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
+ */
+ public int getStep(int index) {
+ return b[offset + 2 * index + 1];
+ }
+
+ /**
+ * Returns the index of the type argument that the given step is stepping
+ * into. This method should only be used for steps whose value is
+ * {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
+ *
+ * @param index
+ * an index between 0 and {@link #getLength()}, exclusive.
+ * @return the index of the type argument that the given step is stepping
+ * into.
+ */
+ public int getStepArgument(int index) {
+ return b[offset + 2 * index + 2];
+ }
+
+ /**
+ * Converts a type path in string form, in the format used by
+ * {@link #toString()}, into a TypePath object.
+ *
+ * @param typePath
+ * a type path in string form, in the format used by
+ * {@link #toString()}. May be null or empty.
+ * @return the corresponding TypePath object, or null if the path is empty.
+ */
+ public static TypePath fromString(final String typePath) {
+ if (typePath == null || typePath.length() == 0) {
+ return null;
+ }
+ int n = typePath.length();
+ ByteVector out = new ByteVector(n);
+ out.putByte(0);
+ for (int i = 0; i < n;) {
+ char c = typePath.charAt(i++);
+ if (c == '[') {
+ out.put11(ARRAY_ELEMENT, 0);
+ } else if (c == '.') {
+ out.put11(INNER_TYPE, 0);
+ } else if (c == '*') {
+ out.put11(WILDCARD_BOUND, 0);
+ } else if (c >= '0' && c <= '9') {
+ int typeArg = c - '0';
+ while (i < n && (c = typePath.charAt(i)) >= '0' && c <= '9') {
+ typeArg = typeArg * 10 + c - '0';
+ i += 1;
+ }
+ if (i < n && typePath.charAt(i) == ';') {
+ i += 1;
+ }
+ out.put11(TYPE_ARGUMENT, typeArg);
+ }
+ }
+ out.data[0] = (byte) (out.length / 2);
+ return new TypePath(out.data, 0);
+ }
+
+ /**
+ * Returns a string representation of this type path. {@link #ARRAY_ELEMENT
+ * ARRAY_ELEMENT} steps are represented with '[', {@link #INNER_TYPE
+ * INNER_TYPE} steps with '.', {@link #WILDCARD_BOUND WILDCARD_BOUND} steps
+ * with '*' and {@link #TYPE_ARGUMENT TYPE_ARGUMENT} steps with their type
+ * argument index in decimal form followed by ';'.
+ */
+ @Override
+ public String toString() {
+ int length = getLength();
+ StringBuilder result = new StringBuilder(length * 2);
+ for (int i = 0; i < length; ++i) {
+ switch (getStep(i)) {
+ case ARRAY_ELEMENT:
+ result.append('[');
+ break;
+ case INNER_TYPE:
+ result.append('.');
+ break;
+ case WILDCARD_BOUND:
+ result.append('*');
+ break;
+ case TYPE_ARGUMENT:
+ result.append(getStepArgument(i)).append(';');
+ break;
+ default:
+ result.append('_');
+ }
+ }
+ return result.toString();
+ }
+}
diff --git a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/TypeReference.java b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/TypeReference.java
index 117d806b9..0b6232a3e 100644
--- a/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/TypeReference.java
+++ b/jersey-server/src/main/java/jersey/repackaged/org/objectweb/asm/TypeReference.java
@@ -1,452 +1,452 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2013 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package jersey.repackaged.org.objectweb.asm;
-
-/**
- * A reference to a type appearing in a class, field or method declaration, or
- * on an instruction. Such a reference designates the part of the class where
- * the referenced type is appearing (e.g. an 'extends', 'implements' or 'throws'
- * clause, a 'new' instruction, a 'catch' clause, a type cast, a local variable
- * declaration, etc).
- *
- * @author Eric Bruneton
- */
-public class TypeReference {
-
- /**
- * The sort of type references that target a type parameter of a generic
- * class. See {@link #getSort getSort}.
- */
- public final static int CLASS_TYPE_PARAMETER = 0x00;
-
- /**
- * The sort of type references that target a type parameter of a generic
- * method. See {@link #getSort getSort}.
- */
- public final static int METHOD_TYPE_PARAMETER = 0x01;
-
- /**
- * The sort of type references that target the super class of a class or one
- * of the interfaces it implements. See {@link #getSort getSort}.
- */
- public final static int CLASS_EXTENDS = 0x10;
-
- /**
- * The sort of type references that target a bound of a type parameter of a
- * generic class. See {@link #getSort getSort}.
- */
- public final static int CLASS_TYPE_PARAMETER_BOUND = 0x11;
-
- /**
- * The sort of type references that target a bound of a type parameter of a
- * generic method. See {@link #getSort getSort}.
- */
- public final static int METHOD_TYPE_PARAMETER_BOUND = 0x12;
-
- /**
- * The sort of type references that target the type of a field. See
- * {@link #getSort getSort}.
- */
- public final static int FIELD = 0x13;
-
- /**
- * The sort of type references that target the return type of a method. See
- * {@link #getSort getSort}.
- */
- public final static int METHOD_RETURN = 0x14;
-
- /**
- * The sort of type references that target the receiver type of a method.
- * See {@link #getSort getSort}.
- */
- public final static int METHOD_RECEIVER = 0x15;
-
- /**
- * The sort of type references that target the type of a formal parameter of
- * a method. See {@link #getSort getSort}.
- */
- public final static int METHOD_FORMAL_PARAMETER = 0x16;
-
- /**
- * The sort of type references that target the type of an exception declared
- * in the throws clause of a method. See {@link #getSort getSort}.
- */
- public final static int THROWS = 0x17;
-
- /**
- * The sort of type references that target the type of a local variable in a
- * method. See {@link #getSort getSort}.
- */
- public final static int LOCAL_VARIABLE = 0x40;
-
- /**
- * The sort of type references that target the type of a resource variable
- * in a method. See {@link #getSort getSort}.
- */
- public final static int RESOURCE_VARIABLE = 0x41;
-
- /**
- * The sort of type references that target the type of the exception of a
- * 'catch' clause in a method. See {@link #getSort getSort}.
- */
- public final static int EXCEPTION_PARAMETER = 0x42;
-
- /**
- * The sort of type references that target the type declared in an
- * 'instanceof' instruction. See {@link #getSort getSort}.
- */
- public final static int INSTANCEOF = 0x43;
-
- /**
- * The sort of type references that target the type of the object created by
- * a 'new' instruction. See {@link #getSort getSort}.
- */
- public final static int NEW = 0x44;
-
- /**
- * The sort of type references that target the receiver type of a
- * constructor reference. See {@link #getSort getSort}.
- */
- public final static int CONSTRUCTOR_REFERENCE = 0x45;
-
- /**
- * The sort of type references that target the receiver type of a method
- * reference. See {@link #getSort getSort}.
- */
- public final static int METHOD_REFERENCE = 0x46;
-
- /**
- * The sort of type references that target the type declared in an explicit
- * or implicit cast instruction. See {@link #getSort getSort}.
- */
- public final static int CAST = 0x47;
-
- /**
- * The sort of type references that target a type parameter of a generic
- * constructor in a constructor call. See {@link #getSort getSort}.
- */
- public final static int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48;
-
- /**
- * The sort of type references that target a type parameter of a generic
- * method in a method call. See {@link #getSort getSort}.
- */
- public final static int METHOD_INVOCATION_TYPE_ARGUMENT = 0x49;
-
- /**
- * The sort of type references that target a type parameter of a generic
- * constructor in a constructor reference. See {@link #getSort getSort}.
- */
- public final static int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A;
-
- /**
- * The sort of type references that target a type parameter of a generic
- * method in a method reference. See {@link #getSort getSort}.
- */
- public final static int METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B;
-
- /**
- * The type reference value in Java class file format.
- */
- private int value;
-
- /**
- * Creates a new TypeReference.
- *
- * @param typeRef
- * the int encoded value of the type reference, as received in a
- * visit method related to type annotations, like
- * visitTypeAnnotation.
- */
- public TypeReference(int typeRef) {
- this.value = typeRef;
- }
-
- /**
- * Returns a type reference of the given sort.
- *
- * @param sort
- * {@link #FIELD FIELD}, {@link #METHOD_RETURN METHOD_RETURN},
- * {@link #METHOD_RECEIVER METHOD_RECEIVER},
- * {@link #LOCAL_VARIABLE LOCAL_VARIABLE},
- * {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE},
- * {@link #INSTANCEOF INSTANCEOF}, {@link #NEW NEW},
- * {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE}, or
- * {@link #METHOD_REFERENCE METHOD_REFERENCE}.
- * @return a type reference of the given sort.
- */
- public static TypeReference newTypeReference(int sort) {
- return new TypeReference(sort << 24);
- }
-
- /**
- * Returns a reference to a type parameter of a generic class or method.
- *
- * @param sort
- * {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or
- * {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER}.
- * @param paramIndex
- * the type parameter index.
- * @return a reference to the given generic class or method type parameter.
- */
- public static TypeReference newTypeParameterReference(int sort,
- int paramIndex) {
- return new TypeReference((sort << 24) | (paramIndex << 16));
- }
-
- /**
- * Returns a reference to a type parameter bound of a generic class or
- * method.
- *
- * @param sort
- * {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or
- * {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER}.
- * @param paramIndex
- * the type parameter index.
- * @param boundIndex
- * the type bound index within the above type parameters.
- * @return a reference to the given generic class or method type parameter
- * bound.
- */
- public static TypeReference newTypeParameterBoundReference(int sort,
- int paramIndex, int boundIndex) {
- return new TypeReference((sort << 24) | (paramIndex << 16)
- | (boundIndex << 8));
- }
-
- /**
- * Returns a reference to the super class or to an interface of the
- * 'implements' clause of a class.
- *
- * @param itfIndex
- * the index of an interface in the 'implements' clause of a
- * class, or -1 to reference the super class of the class.
- * @return a reference to the given super type of a class.
- */
- public static TypeReference newSuperTypeReference(int itfIndex) {
- itfIndex &= 0xFFFF;
- return new TypeReference((CLASS_EXTENDS << 24) | (itfIndex << 8));
- }
-
- /**
- * Returns a reference to the type of a formal parameter of a method.
- *
- * @param paramIndex
- * the formal parameter index.
- *
- * @return a reference to the type of the given method formal parameter.
- */
- public static TypeReference newFormalParameterReference(int paramIndex) {
- return new TypeReference((METHOD_FORMAL_PARAMETER << 24)
- | (paramIndex << 16));
- }
-
- /**
- * Returns a reference to the type of an exception, in a 'throws' clause of
- * a method.
- *
- * @param exceptionIndex
- * the index of an exception in a 'throws' clause of a method.
- *
- * @return a reference to the type of the given exception.
- */
- public static TypeReference newExceptionReference(int exceptionIndex) {
- return new TypeReference((THROWS << 24) | (exceptionIndex << 8));
- }
-
- /**
- * Returns a reference to the type of the exception declared in a 'catch'
- * clause of a method.
- *
- * @param tryCatchBlockIndex
- * the index of a try catch block (using the order in which they
- * are visited with visitTryCatchBlock).
- *
- * @return a reference to the type of the given exception.
- */
- public static TypeReference newTryCatchReference(int tryCatchBlockIndex) {
- return new TypeReference((EXCEPTION_PARAMETER << 24)
- | (tryCatchBlockIndex << 8));
- }
-
- /**
- * Returns a reference to the type of a type argument in a constructor or
- * method call or reference.
- *
- * @param sort
- * {@link #CAST CAST},
- * {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
- * CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
- * {@link #METHOD_INVOCATION_TYPE_ARGUMENT
- * METHOD_INVOCATION_TYPE_ARGUMENT},
- * {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
- * CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
- * {@link #METHOD_REFERENCE_TYPE_ARGUMENT
- * METHOD_REFERENCE_TYPE_ARGUMENT}.
- * @param argIndex
- * the type argument index.
- *
- * @return a reference to the type of the given type argument.
- */
- public static TypeReference newTypeArgumentReference(int sort, int argIndex) {
- return new TypeReference((sort << 24) | argIndex);
- }
-
- /**
- * Returns the sort of this type reference.
- *
- * @return {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
- * {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
- * {@link #CLASS_EXTENDS CLASS_EXTENDS},
- * {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND},
- * {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND},
- * {@link #FIELD FIELD}, {@link #METHOD_RETURN METHOD_RETURN},
- * {@link #METHOD_RECEIVER METHOD_RECEIVER},
- * {@link #METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER},
- * {@link #THROWS THROWS}, {@link #LOCAL_VARIABLE LOCAL_VARIABLE},
- * {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE},
- * {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER},
- * {@link #INSTANCEOF INSTANCEOF}, {@link #NEW NEW},
- * {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE},
- * {@link #METHOD_REFERENCE METHOD_REFERENCE}, {@link #CAST CAST},
- * {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
- * CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
- * {@link #METHOD_INVOCATION_TYPE_ARGUMENT
- * METHOD_INVOCATION_TYPE_ARGUMENT},
- * {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
- * CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
- * {@link #METHOD_REFERENCE_TYPE_ARGUMENT
- * METHOD_REFERENCE_TYPE_ARGUMENT}.
- */
- public int getSort() {
- return value >>> 24;
- }
-
- /**
- * Returns the index of the type parameter referenced by this type
- * reference. This method must only be used for type references whose sort
- * is {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
- * {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
- * {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
- * {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND}.
- *
- * @return a type parameter index.
- */
- public int getTypeParameterIndex() {
- return (value & 0x00FF0000) >> 16;
- }
-
- /**
- * Returns the index of the type parameter bound, within the type parameter
- * {@link #getTypeParameterIndex}, referenced by this type reference. This
- * method must only be used for type references whose sort is
- * {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
- * {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND}.
- *
- * @return a type parameter bound index.
- */
- public int getTypeParameterBoundIndex() {
- return (value & 0x0000FF00) >> 8;
- }
-
- /**
- * Returns the index of the "super type" of a class that is referenced by
- * this type reference. This method must only be used for type references
- * whose sort is {@link #CLASS_EXTENDS CLASS_EXTENDS}.
- *
- * @return the index of an interface in the 'implements' clause of a class,
- * or -1 if this type reference references the type of the super
- * class.
- */
- public int getSuperTypeIndex() {
- return (short) ((value & 0x00FFFF00) >> 8);
- }
-
- /**
- * Returns the index of the formal parameter whose type is referenced by
- * this type reference. This method must only be used for type references
- * whose sort is {@link #METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER}.
- *
- * @return a formal parameter index.
- */
- public int getFormalParameterIndex() {
- return (value & 0x00FF0000) >> 16;
- }
-
- /**
- * Returns the index of the exception, in a 'throws' clause of a method,
- * whose type is referenced by this type reference. This method must only be
- * used for type references whose sort is {@link #THROWS THROWS}.
- *
- * @return the index of an exception in the 'throws' clause of a method.
- */
- public int getExceptionIndex() {
- return (value & 0x00FFFF00) >> 8;
- }
-
- /**
- * Returns the index of the try catch block (using the order in which they
- * are visited with visitTryCatchBlock), whose 'catch' type is referenced by
- * this type reference. This method must only be used for type references
- * whose sort is {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER} .
- *
- * @return the index of an exception in the 'throws' clause of a method.
- */
- public int getTryCatchBlockIndex() {
- return (value & 0x00FFFF00) >> 8;
- }
-
- /**
- * Returns the index of the type argument referenced by this type reference.
- * This method must only be used for type references whose sort is
- * {@link #CAST CAST}, {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
- * CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
- * {@link #METHOD_INVOCATION_TYPE_ARGUMENT METHOD_INVOCATION_TYPE_ARGUMENT},
- * {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
- * CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
- * {@link #METHOD_REFERENCE_TYPE_ARGUMENT METHOD_REFERENCE_TYPE_ARGUMENT}.
- *
- * @return a type parameter index.
- */
- public int getTypeArgumentIndex() {
- return value & 0xFF;
- }
-
- /**
- * Returns the int encoded value of this type reference, suitable for use in
- * visit methods related to type annotations, like visitTypeAnnotation.
- *
- * @return the int encoded value of this type reference.
- */
- public int getValue() {
- return value;
- }
-}
+/***
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2013 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package jersey.repackaged.org.objectweb.asm;
+
+/**
+ * A reference to a type appearing in a class, field or method declaration, or
+ * on an instruction. Such a reference designates the part of the class where
+ * the referenced type is appearing (e.g. an 'extends', 'implements' or 'throws'
+ * clause, a 'new' instruction, a 'catch' clause, a type cast, a local variable
+ * declaration, etc).
+ *
+ * @author Eric Bruneton
+ */
+public class TypeReference {
+
+ /**
+ * The sort of type references that target a type parameter of a generic
+ * class. See {@link #getSort getSort}.
+ */
+ public final static int CLASS_TYPE_PARAMETER = 0x00;
+
+ /**
+ * The sort of type references that target a type parameter of a generic
+ * method. See {@link #getSort getSort}.
+ */
+ public final static int METHOD_TYPE_PARAMETER = 0x01;
+
+ /**
+ * The sort of type references that target the super class of a class or one
+ * of the interfaces it implements. See {@link #getSort getSort}.
+ */
+ public final static int CLASS_EXTENDS = 0x10;
+
+ /**
+ * The sort of type references that target a bound of a type parameter of a
+ * generic class. See {@link #getSort getSort}.
+ */
+ public final static int CLASS_TYPE_PARAMETER_BOUND = 0x11;
+
+ /**
+ * The sort of type references that target a bound of a type parameter of a
+ * generic method. See {@link #getSort getSort}.
+ */
+ public final static int METHOD_TYPE_PARAMETER_BOUND = 0x12;
+
+ /**
+ * The sort of type references that target the type of a field. See
+ * {@link #getSort getSort}.
+ */
+ public final static int FIELD = 0x13;
+
+ /**
+ * The sort of type references that target the return type of a method. See
+ * {@link #getSort getSort}.
+ */
+ public final static int METHOD_RETURN = 0x14;
+
+ /**
+ * The sort of type references that target the receiver type of a method.
+ * See {@link #getSort getSort}.
+ */
+ public final static int METHOD_RECEIVER = 0x15;
+
+ /**
+ * The sort of type references that target the type of a formal parameter of
+ * a method. See {@link #getSort getSort}.
+ */
+ public final static int METHOD_FORMAL_PARAMETER = 0x16;
+
+ /**
+ * The sort of type references that target the type of an exception declared
+ * in the throws clause of a method. See {@link #getSort getSort}.
+ */
+ public final static int THROWS = 0x17;
+
+ /**
+ * The sort of type references that target the type of a local variable in a
+ * method. See {@link #getSort getSort}.
+ */
+ public final static int LOCAL_VARIABLE = 0x40;
+
+ /**
+ * The sort of type references that target the type of a resource variable
+ * in a method. See {@link #getSort getSort}.
+ */
+ public final static int RESOURCE_VARIABLE = 0x41;
+
+ /**
+ * The sort of type references that target the type of the exception of a
+ * 'catch' clause in a method. See {@link #getSort getSort}.
+ */
+ public final static int EXCEPTION_PARAMETER = 0x42;
+
+ /**
+ * The sort of type references that target the type declared in an
+ * 'instanceof' instruction. See {@link #getSort getSort}.
+ */
+ public final static int INSTANCEOF = 0x43;
+
+ /**
+ * The sort of type references that target the type of the object created by
+ * a 'new' instruction. See {@link #getSort getSort}.
+ */
+ public final static int NEW = 0x44;
+
+ /**
+ * The sort of type references that target the receiver type of a
+ * constructor reference. See {@link #getSort getSort}.
+ */
+ public final static int CONSTRUCTOR_REFERENCE = 0x45;
+
+ /**
+ * The sort of type references that target the receiver type of a method
+ * reference. See {@link #getSort getSort}.
+ */
+ public final static int METHOD_REFERENCE = 0x46;
+
+ /**
+ * The sort of type references that target the type declared in an explicit
+ * or implicit cast instruction. See {@link #getSort getSort}.
+ */
+ public final static int CAST = 0x47;
+
+ /**
+ * The sort of type references that target a type parameter of a generic
+ * constructor in a constructor call. See {@link #getSort getSort}.
+ */
+ public final static int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48;
+
+ /**
+ * The sort of type references that target a type parameter of a generic
+ * method in a method call. See {@link #getSort getSort}.
+ */
+ public final static int METHOD_INVOCATION_TYPE_ARGUMENT = 0x49;
+
+ /**
+ * The sort of type references that target a type parameter of a generic
+ * constructor in a constructor reference. See {@link #getSort getSort}.
+ */
+ public final static int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A;
+
+ /**
+ * The sort of type references that target a type parameter of a generic
+ * method in a method reference. See {@link #getSort getSort}.
+ */
+ public final static int METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B;
+
+ /**
+ * The type reference value in Java class file format.
+ */
+ private int value;
+
+ /**
+ * Creates a new TypeReference.
+ *
+ * @param typeRef
+ * the int encoded value of the type reference, as received in a
+ * visit method related to type annotations, like
+ * visitTypeAnnotation.
+ */
+ public TypeReference(int typeRef) {
+ this.value = typeRef;
+ }
+
+ /**
+ * Returns a type reference of the given sort.
+ *
+ * @param sort
+ * {@link #FIELD FIELD}, {@link #METHOD_RETURN METHOD_RETURN},
+ * {@link #METHOD_RECEIVER METHOD_RECEIVER},
+ * {@link #LOCAL_VARIABLE LOCAL_VARIABLE},
+ * {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE},
+ * {@link #INSTANCEOF INSTANCEOF}, {@link #NEW NEW},
+ * {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE}, or
+ * {@link #METHOD_REFERENCE METHOD_REFERENCE}.
+ * @return a type reference of the given sort.
+ */
+ public static TypeReference newTypeReference(int sort) {
+ return new TypeReference(sort << 24);
+ }
+
+ /**
+ * Returns a reference to a type parameter of a generic class or method.
+ *
+ * @param sort
+ * {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or
+ * {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER}.
+ * @param paramIndex
+ * the type parameter index.
+ * @return a reference to the given generic class or method type parameter.
+ */
+ public static TypeReference newTypeParameterReference(int sort,
+ int paramIndex) {
+ return new TypeReference((sort << 24) | (paramIndex << 16));
+ }
+
+ /**
+ * Returns a reference to a type parameter bound of a generic class or
+ * method.
+ *
+ * @param sort
+ * {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or
+ * {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER}.
+ * @param paramIndex
+ * the type parameter index.
+ * @param boundIndex
+ * the type bound index within the above type parameters.
+ * @return a reference to the given generic class or method type parameter
+ * bound.
+ */
+ public static TypeReference newTypeParameterBoundReference(int sort,
+ int paramIndex, int boundIndex) {
+ return new TypeReference((sort << 24) | (paramIndex << 16)
+ | (boundIndex << 8));
+ }
+
+ /**
+ * Returns a reference to the super class or to an interface of the
+ * 'implements' clause of a class.
+ *
+ * @param itfIndex
+ * the index of an interface in the 'implements' clause of a
+ * class, or -1 to reference the super class of the class.
+ * @return a reference to the given super type of a class.
+ */
+ public static TypeReference newSuperTypeReference(int itfIndex) {
+ itfIndex &= 0xFFFF;
+ return new TypeReference((CLASS_EXTENDS << 24) | (itfIndex << 8));
+ }
+
+ /**
+ * Returns a reference to the type of a formal parameter of a method.
+ *
+ * @param paramIndex
+ * the formal parameter index.
+ *
+ * @return a reference to the type of the given method formal parameter.
+ */
+ public static TypeReference newFormalParameterReference(int paramIndex) {
+ return new TypeReference((METHOD_FORMAL_PARAMETER << 24)
+ | (paramIndex << 16));
+ }
+
+ /**
+ * Returns a reference to the type of an exception, in a 'throws' clause of
+ * a method.
+ *
+ * @param exceptionIndex
+ * the index of an exception in a 'throws' clause of a method.
+ *
+ * @return a reference to the type of the given exception.
+ */
+ public static TypeReference newExceptionReference(int exceptionIndex) {
+ return new TypeReference((THROWS << 24) | (exceptionIndex << 8));
+ }
+
+ /**
+ * Returns a reference to the type of the exception declared in a 'catch'
+ * clause of a method.
+ *
+ * @param tryCatchBlockIndex
+ * the index of a try catch block (using the order in which they
+ * are visited with visitTryCatchBlock).
+ *
+ * @return a reference to the type of the given exception.
+ */
+ public static TypeReference newTryCatchReference(int tryCatchBlockIndex) {
+ return new TypeReference((EXCEPTION_PARAMETER << 24)
+ | (tryCatchBlockIndex << 8));
+ }
+
+ /**
+ * Returns a reference to the type of a type argument in a constructor or
+ * method call or reference.
+ *
+ * @param sort
+ * {@link #CAST CAST},
+ * {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
+ * CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
+ * {@link #METHOD_INVOCATION_TYPE_ARGUMENT
+ * METHOD_INVOCATION_TYPE_ARGUMENT},
+ * {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
+ * CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
+ * {@link #METHOD_REFERENCE_TYPE_ARGUMENT
+ * METHOD_REFERENCE_TYPE_ARGUMENT}.
+ * @param argIndex
+ * the type argument index.
+ *
+ * @return a reference to the type of the given type argument.
+ */
+ public static TypeReference newTypeArgumentReference(int sort, int argIndex) {
+ return new TypeReference((sort << 24) | argIndex);
+ }
+
+ /**
+ * Returns the sort of this type reference.
+ *
+ * @return {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
+ * {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
+ * {@link #CLASS_EXTENDS CLASS_EXTENDS},
+ * {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND},
+ * {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND},
+ * {@link #FIELD FIELD}, {@link #METHOD_RETURN METHOD_RETURN},
+ * {@link #METHOD_RECEIVER METHOD_RECEIVER},
+ * {@link #METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER},
+ * {@link #THROWS THROWS}, {@link #LOCAL_VARIABLE LOCAL_VARIABLE},
+ * {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE},
+ * {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER},
+ * {@link #INSTANCEOF INSTANCEOF}, {@link #NEW NEW},
+ * {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE},
+ * {@link #METHOD_REFERENCE METHOD_REFERENCE}, {@link #CAST CAST},
+ * {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
+ * CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
+ * {@link #METHOD_INVOCATION_TYPE_ARGUMENT
+ * METHOD_INVOCATION_TYPE_ARGUMENT},
+ * {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
+ * CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
+ * {@link #METHOD_REFERENCE_TYPE_ARGUMENT
+ * METHOD_REFERENCE_TYPE_ARGUMENT}.
+ */
+ public int getSort() {
+ return value >>> 24;
+ }
+
+ /**
+ * Returns the index of the type parameter referenced by this type
+ * reference. This method must only be used for type references whose sort
+ * is {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
+ * {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
+ * {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
+ * {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND}.
+ *
+ * @return a type parameter index.
+ */
+ public int getTypeParameterIndex() {
+ return (value & 0x00FF0000) >> 16;
+ }
+
+ /**
+ * Returns the index of the type parameter bound, within the type parameter
+ * {@link #getTypeParameterIndex}, referenced by this type reference. This
+ * method must only be used for type references whose sort is
+ * {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
+ * {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND}.
+ *
+ * @return a type parameter bound index.
+ */
+ public int getTypeParameterBoundIndex() {
+ return (value & 0x0000FF00) >> 8;
+ }
+
+ /**
+ * Returns the index of the "super type" of a class that is referenced by
+ * this type reference. This method must only be used for type references
+ * whose sort is {@link #CLASS_EXTENDS CLASS_EXTENDS}.
+ *
+ * @return the index of an interface in the 'implements' clause of a class,
+ * or -1 if this type reference references the type of the super
+ * class.
+ */
+ public int getSuperTypeIndex() {
+ return (short) ((value & 0x00FFFF00) >> 8);
+ }
+
+ /**
+ * Returns the index of the formal parameter whose type is referenced by
+ * this type reference. This method must only be used for type references
+ * whose sort is {@link #METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER}.
+ *
+ * @return a formal parameter index.
+ */
+ public int getFormalParameterIndex() {
+ return (value & 0x00FF0000) >> 16;
+ }
+
+ /**
+ * Returns the index of the exception, in a 'throws' clause of a method,
+ * whose type is referenced by this type reference. This method must only be
+ * used for type references whose sort is {@link #THROWS THROWS}.
+ *
+ * @return the index of an exception in the 'throws' clause of a method.
+ */
+ public int getExceptionIndex() {
+ return (value & 0x00FFFF00) >> 8;
+ }
+
+ /**
+ * Returns the index of the try catch block (using the order in which they
+ * are visited with visitTryCatchBlock), whose 'catch' type is referenced by
+ * this type reference. This method must only be used for type references
+ * whose sort is {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER} .
+ *
+ * @return the index of an exception in the 'throws' clause of a method.
+ */
+ public int getTryCatchBlockIndex() {
+ return (value & 0x00FFFF00) >> 8;
+ }
+
+ /**
+ * Returns the index of the type argument referenced by this type reference.
+ * This method must only be used for type references whose sort is
+ * {@link #CAST CAST}, {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
+ * CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
+ * {@link #METHOD_INVOCATION_TYPE_ARGUMENT METHOD_INVOCATION_TYPE_ARGUMENT},
+ * {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
+ * CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
+ * {@link #METHOD_REFERENCE_TYPE_ARGUMENT METHOD_REFERENCE_TYPE_ARGUMENT}.
+ *
+ * @return a type parameter index.
+ */
+ public int getTypeArgumentIndex() {
+ return value & 0xFF;
+ }
+
+ /**
+ * Returns the int encoded value of this type reference, suitable for use in
+ * visit methods related to type annotations, like visitTypeAnnotation.
+ *
+ * @return the int encoded value of this type reference.
+ */
+ public int getValue() {
+ return value;
+ }
+}