Skip to content

Commit

Permalink
Update ASM to 7.2 (#4279)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Supol <jan.supol@oracle.com>
  • Loading branch information
jansupol authored and senivam committed Oct 3, 2019
1 parent 94945df commit 584664c
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public abstract class AnnotationVisitor {
*/
protected final int api;

/** The annotation visitor to which this visitor must delegate method calls. May be null. */
/**
* The annotation visitor to which this visitor must delegate method calls. May be {@literal
* null}.
*/
protected AnnotationVisitor av;

/**
Expand All @@ -62,7 +65,7 @@ public AnnotationVisitor(final int api) {
* @param api the ASM API version implemented by this visitor. Must be one of {@link
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
* @param annotationVisitor the annotation visitor to which this visitor must delegate method
* calls. May be null.
* calls. May be {@literal null}.
*/
public AnnotationVisitor(final int api, final AnnotationVisitor annotationVisitor) {
if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ final class AnnotationWriter extends AnnotationVisitor {
* the visited content must be stored. This ByteVector must already contain all the fields of
* the structure except the last one (the element_value_pairs array).
* @param previousAnnotation the previously visited annotation of the
* Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or null in
* other cases (e.g. nested or array annotations).
* Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or
* {@literal null} in other cases (e.g. nested or array annotations).
*/
AnnotationWriter(
final SymbolTable symbolTable,
Expand All @@ -130,8 +130,9 @@ final class AnnotationWriter extends AnnotationVisitor {
* @param symbolTable where the constants used in this AnnotationWriter must be stored.
* @param descriptor the class descriptor of the annotation class.
* @param previousAnnotation the previously visited annotation of the
* Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or null in
* other cases (e.g. nested or array annotations).
* Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or
* {@literal null} in other cases (e.g. nested or array annotations).
* @return a new {@link AnnotationWriter} for the given annotation descriptor.
*/
static AnnotationWriter create(
final SymbolTable symbolTable,
Expand Down Expand Up @@ -159,8 +160,9 @@ static AnnotationWriter create(
* 'typeRef' as a whole.
* @param descriptor the class descriptor of the annotation class.
* @param previousAnnotation the previously visited annotation of the
* Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or null in
* other cases (e.g. nested or array annotations).
* Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or
* {@literal null} in other cases (e.g. nested or array annotations).
* @return a new {@link AnnotationWriter} for the given type annotation reference and descriptor.
*/
static AnnotationWriter create(
final SymbolTable symbolTable,
Expand Down Expand Up @@ -322,7 +324,7 @@ public void visitEnd() {
* and all its <i>predecessors</i> (see {@link #previousAnnotation}. Also adds the attribute name
* to the constant pool of the class (if not null).
*
* @param attributeName one of "Runtime[In]Visible[Type]Annotations", or null.
* @param attributeName one of "Runtime[In]Visible[Type]Annotations", or {@literal null}.
* @return the size in bytes of a Runtime[In]Visible[Type]Annotations attribute containing this
* annotation and all its predecessors. This includes the size of the attribute_name_index and
* attribute_length fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ public ClassReader(
this.b = classFileBuffer;
// Check the class' major_version. This field is after the magic and minor_version fields, which
// use 4 and 2 bytes respectively.
if (checkClassVersion && readShort(classFileOffset + 6) == Opcodes.V14) {
if (checkClassVersion && readShort(classFileOffset + 6) == Opcodes.V15) {
LOGGER.warning("Unsupported class file major version " + readShort(classFileOffset + 6));
}
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V14) {
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V15) {
throw new IllegalArgumentException(
"Unsupported class file major version " + readShort(classFileOffset + 6));
}
Expand Down Expand Up @@ -711,7 +711,8 @@ public void accept(
* attribute_name_index and attribute_length fields).
* @param modulePackagesOffset the offset of the ModulePackages attribute (excluding the
* attribute_info's attribute_name_index and attribute_length fields), or 0.
* @param moduleMainClass the string corresponding to the ModuleMainClass attribute, or null.
* @param moduleMainClass the string corresponding to the ModuleMainClass attribute, or {@literal
* null}.
*/
private void readModuleAttributes(
final ClassVisitor classVisitor,
Expand Down Expand Up @@ -2599,7 +2600,7 @@ private int[] readTypeAnnotations(
* -1 if there is no such type_annotation of if it does not have a bytecode offset.
*
* @param typeAnnotationOffsets the offset of each 'type_annotation' entry in a
* Runtime[In]VisibleTypeAnnotations attribute, or null.
* Runtime[In]VisibleTypeAnnotations attribute, or {@literal null}.
* @param typeAnnotationIndex the index a 'type_annotation' entry in typeAnnotationOffsets.
* @return bytecode offset corresponding to the specified JVMS 'type_annotation' structure, or -1
* if there is no such type_annotation of if it does not have a bytecode offset.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class ClassVisitor {
*/
protected final int api;

/** The class visitor to which this visitor must delegate method calls. May be null. */
/** The class visitor to which this visitor must delegate method calls. May be {@literal null}. */
protected ClassVisitor cv;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public final ModuleVisitor visitModule(
}

@Override
public void visitNestHost(final String nestHost) {
public final void visitNestHost(final String nestHost) {
nestHostClassIndex = symbolTable.addConstantClass(nestHost).index;
}

Expand Down Expand Up @@ -344,7 +344,7 @@ public final void visitAttribute(final Attribute attribute) {
}

@Override
public void visitNestMember(final String nestMember) {
public final void visitNestMember(final String nestMember) {
if (nestMemberClasses == null) {
nestMemberClasses = new ByteVector();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ public int getSize() {
return (firstCharOfDescriptor == 'J' || firstCharOfDescriptor == 'D') ? 2 : 1;
}

void accept(final MethodVisitor methodVisitor) {
methodVisitor.visitInvokeDynamicInsn(
name, descriptor, bootstrapMethod, bootstrapMethodArguments);
}

@Override
public boolean equals(final Object object) {
if (object == this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class FieldVisitor {
*/
protected final int api;

/** The field visitor to which this visitor must delegate method calls. May be null. */
/** The field visitor to which this visitor must delegate method calls. May be {@literal null}. */
protected FieldVisitor fv;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@
* <p>Output frames can contain abstract types of any kind and with a positive or negative array
* dimension (and even unassigned types, represented by 0 - which does not correspond to any valid
* abstract type value). Input frames can only contain CONSTANT_KIND, REFERENCE_KIND or
* UNINITIALIZED_KIND abstract types of positive or null array dimension. In all cases the type
* table contains only internal type names (array type descriptors are forbidden - array dimensions
* must be represented through the DIM field).
* UNINITIALIZED_KIND abstract types of positive or {@literal null} array dimension. In all cases
* the type table contains only internal type names (array type descriptors are forbidden - array
* dimensions must be represented through the DIM field).
*
* <p>The LONG and DOUBLE types are always represented by using two slots (LONG + TOP or DOUBLE +
* TOP), for local variables as well as in the operand stack. This is necessary to be able to
Expand Down Expand Up @@ -1253,10 +1253,10 @@ final boolean merge(
* @param symbolTable the type table to use to lookup and store type {@link Symbol}.
* @param sourceType the abstract type with which the abstract type array element must be merged.
* This type should be of {@link #CONSTANT_KIND}, {@link #REFERENCE_KIND} or {@link
* #UNINITIALIZED_KIND} kind, with positive or null array dimensions.
* #UNINITIALIZED_KIND} kind, with positive or {@literal null} array dimensions.
* @param dstTypes an array of abstract types. These types should be of {@link #CONSTANT_KIND},
* {@link #REFERENCE_KIND} or {@link #UNINITIALIZED_KIND} kind, with positive or null array
* dimensions.
* {@link #REFERENCE_KIND} or {@link #UNINITIALIZED_KIND} kind, with positive or {@literal
* null} array dimensions.
* @param dstIndex the index of the type that must be merged in dstTypes.
* @return {@literal true} if the type array has been modified by this operation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ public class Label {

/**
* The maximum height reached by the output stack, relatively to the top of the input stack, in
* the basic block corresponding to this label. This maximum is always positive or null.
* the basic block corresponding to this label. This maximum is always positive or {@literal
* null}.
*/
short outputStackMax;

Expand Down Expand Up @@ -264,12 +265,12 @@ public class Label {
Edge outgoingEdges;

/**
* The next element in the list of labels to which this label belongs, or null if it does not
* belong to any list. All lists of labels must end with the {@link #EMPTY_LIST} sentinel, in
* order to ensure that this field is null if and only if this label does not belong to a list of
* labels. Note that there can be several lists of labels at the same time, but that a label can
* belong to at most one list at a time (unless some lists share a common tail, but this is not
* used in practice).
* The next element in the list of labels to which this label belongs, or {@literal null} if it
* does not belong to any list. All lists of labels must end with the {@link #EMPTY_LIST}
* sentinel, in order to ensure that this field is null if and only if this label does not belong
* to a list of labels. Note that there can be several lists of labels at the same time, but that
* a label can belong to at most one list at a time (unless some lists share a common tail, but
* this is not used in practice).
*
* <p>List of labels are used in {@link MethodWriter#computeAllFrames} and {@link
* MethodWriter#computeMaxStackAndLocal} to compute stack map frames and the maximum stack size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public abstract class MethodVisitor {
*/
protected final int api;

/** The method visitor to which this visitor must delegate method calls. May be null. */
/**
* The method visitor to which this visitor must delegate method calls. May be {@literal null}.
*/
protected MethodVisitor mv;

/**
Expand Down Expand Up @@ -92,7 +94,7 @@ public MethodVisitor(final int api, final MethodVisitor methodVisitor) {
/**
* Visits a parameter of this method.
*
* @param name parameter name or null if none is provided.
* @param name parameter name or {@literal null} if none is provided.
* @param access the parameter's access flags, only {@code ACC_FINAL}, {@code ACC_SYNTHETIC}
* or/and {@code ACC_MANDATED} are allowed (see {@link Opcodes}).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,9 @@ public void visitFrame(
}
visitFrameEnd();
} else {
if (symbolTable.getMajorVersion() < Opcodes.V1_6) {
throw new IllegalArgumentException("Class versions V1_5 or less must use F_NEW frames.");
}
int offsetDelta;
if (stackMapTableEntries == null) {
stackMapTableEntries = new ByteVector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public abstract class ModuleVisitor {
*/
protected final int api;

/** The module visitor to which this visitor must delegate method calls. May be null. */
/**
* The module visitor to which this visitor must delegate method calls. May be {@literal null}.
*/
protected ModuleVisitor mv;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public interface Opcodes {
int V12 = 0 << 16 | 56;
int V13 = 0 << 16 | 57;
int V14 = 0 << 16 | 58;
int V15 = 0 << 16 | 59;

/**
* Version flag indicating that the class is using 'preview' features.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ public static Type[] getArgumentTypes(final String methodDescriptor) {
}
if (methodDescriptor.charAt(currentOffset++) == 'L') {
// Skip the argument descriptor content.
currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1;
int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
}
++numArgumentTypes;
}
Expand All @@ -323,7 +324,8 @@ public static Type[] getArgumentTypes(final String methodDescriptor) {
}
if (methodDescriptor.charAt(currentOffset++) == 'L') {
// Skip the argument descriptor content.
currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1;
int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
}
argumentTypes[currentArgumentTypeIndex++] =
getTypeInternal(methodDescriptor, currentArgumentTypeOffset, currentOffset);
Expand Down Expand Up @@ -393,7 +395,8 @@ static int getReturnTypeOffset(final String methodDescriptor) {
}
if (methodDescriptor.charAt(currentOffset++) == 'L') {
// Skip the argument descriptor content.
currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1;
int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
}
}
return currentOffset + 1;
Expand Down Expand Up @@ -737,7 +740,8 @@ public static int getArgumentsAndReturnSizes(final String methodDescriptor) {
}
if (methodDescriptor.charAt(currentOffset++) == 'L') {
// Skip the argument descriptor content.
currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1;
int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
}
argumentsSize += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,7 @@
<jersey.version>${project.version}</jersey.version>
<!-- asm is now source integrated - keeping this property to see the version -->
<!-- see core-server/src/main/java/jersey/repackaged/asm/.. -->
<asm.version>7.1</asm.version>
<asm.version>7.2</asm.version>
<bnd.plugin.version>2.3.6</bnd.plugin.version>
<cdi.api.version>1.1</cdi.api.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
Expand Down

0 comments on commit 584664c

Please sign in to comment.