Skip to content

Commit

Permalink
8323835: Updating ASM to 9.6 for JDK 23
Browse files Browse the repository at this point in the history
Reviewed-by: mchung
  • Loading branch information
Vicente Romero committed Jan 26, 2024
1 parent a65a895 commit 91d8ea7
Show file tree
Hide file tree
Showing 127 changed files with 1,355 additions and 503 deletions.
Expand Up @@ -112,6 +112,17 @@ protected AnnotationVisitor(final int api, final AnnotationVisitor annotationVis
this.av = annotationVisitor;
}

/**
* The annotation visitor to which this visitor must delegate method calls. May be {@literal
* null}.
*
* @return the annotation visitor to which this visitor must delegate method calls, or {@literal
* null}.
*/
public AnnotationVisitor getDelegate() {
return av;
}

/**
* Visits a primitive value of the annotation.
*
Expand Down
Expand Up @@ -403,4 +403,3 @@ private void enlarge(final int size) {
data = newData;
}
}

Expand Up @@ -407,7 +407,7 @@ public String getClassName() {
}

/**
* Returns the internal of name of the super class (see {@link Type#getInternalName()}). For
* Returns the internal name of the super class (see {@link Type#getInternalName()}). For
* interfaces, the super class is {@link Object}.
*
* @return the internal name of the super class, or {@literal null} for {@link Object} class.
Expand Down Expand Up @@ -2082,6 +2082,7 @@ private void readCode(
currentOffset = bytecodeStartOffset;
while (currentOffset < bytecodeEndOffset) {
final int currentBytecodeOffset = currentOffset - bytecodeStartOffset;
readBytecodeInstructionOffset(currentBytecodeOffset);

// Visit the label and the line number(s) for this bytecode offset, if any.
Label currentLabel = labels[currentBytecodeOffset];
Expand Down Expand Up @@ -2697,6 +2698,20 @@ private void readCode(
methodVisitor.visitMaxs(maxStack, maxLocals);
}

/**
* Handles the bytecode offset of the next instruction to be visited in {@link
* #accept(ClassVisitor,int)}. This method is called just before the instruction and before its
* associated label and stack map frame, if any. The default implementation of this method does
* nothing. Subclasses can override this method to store the argument in a mutable field, for
* instance, so that {@link MethodVisitor} instances can get the bytecode offset of each visited
* instruction (if so, the usual concurrency issues related to mutable data should be addressed).
*
* @param bytecodeOffset the bytecode offset of the next instruction to be visited.
*/
protected void readBytecodeInstructionOffset(final int bytecodeOffset) {
// Do nothing by default.
}

/**
* Returns the label corresponding to the given bytecode offset. The default implementation of
* this method creates a label for the given offset if it has not been already created.
Expand Down Expand Up @@ -3882,4 +3897,3 @@ public Object readConst(final int constantPoolEntryIndex, final char[] charBuffe
}
}
}

Expand Up @@ -74,7 +74,8 @@ public final class ClassTooLargeException extends IndexOutOfBoundsException {
/**
* Constructs a new {@link ClassTooLargeException}.
*
* @param className the internal name of the class.
* @param className the internal name of the class (see {@link
* jdk.internal.org.objectweb.asm.Type#getInternalName()}).
* @param constantPoolCount the number of constant pool items of the class.
*/
public ClassTooLargeException(final String className, final int constantPoolCount) {
Expand All @@ -84,7 +85,7 @@ public ClassTooLargeException(final String className, final int constantPoolCoun
}

/**
* Returns the internal name of the class.
* Returns the internal name of the class (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}).
*
* @return the internal name of the class.
*/
Expand All @@ -101,4 +102,3 @@ public int getConstantPoolCount() {
return constantPoolCount;
}
}

Expand Up @@ -111,6 +111,15 @@ protected ClassVisitor(final int api, final ClassVisitor classVisitor) {
this.cv = classVisitor;
}

/**
* The class visitor to which this visitor must delegate method calls. May be {@literal null}.
*
* @return the class visitor to which this visitor must delegate method calls, or {@literal null}.
*/
public ClassVisitor getDelegate() {
return cv;
}

/**
* Visits the header of the class.
*
Expand Down Expand Up @@ -185,7 +194,8 @@ public ModuleVisitor visitModule(final String name, final int access, final Stri
* implicitly its own nest, so it's invalid to call this method with the visited class name as
* argument.
*
* @param nestHost the internal name of the host class of the nest.
* @param nestHost the internal name of the host class of the nest (see {@link
* Type#getInternalName()}).
*/
public void visitNestHost(final String nestHost) {
if (api < Opcodes.ASM7) {
Expand All @@ -197,14 +207,19 @@ public void visitNestHost(final String nestHost) {
}

/**
* Visits the enclosing class of the class. This method must be called only if the class has an
* enclosing class.
* Visits the enclosing class of the class. This method must be called only if this class is a
* local or anonymous class. See the JVMS 4.7.7 section for more details.
*
* @param owner internal name of the enclosing class of the class.
* @param owner internal name of the enclosing class of the class (see {@link
* Type#getInternalName()}).
* @param name the name of the method that contains the class, or {@literal null} if the class is
* not enclosed in a method of its enclosing class.
* not enclosed in a method or constructor of its enclosing class (e.g. if it is enclosed in
* an instance initializer, static initializer, instance variable initializer, or class
* variable initializer).
* @param descriptor the descriptor of the method that contains the class, or {@literal null} if
* the class is not enclosed in a method of its enclosing class.
* the class is not enclosed in a method or constructor of its enclosing class (e.g. if it is
* enclosed in an instance initializer, static initializer, instance variable initializer, or
* class variable initializer).
*/
public void visitOuterClass(final String owner, final String name, final String descriptor) {
if (cv != null) {
Expand Down Expand Up @@ -271,7 +286,7 @@ public void visitAttribute(final Attribute attribute) {
* the visited class is the host of a nest. A nest host is implicitly a member of its own nest, so
* it's invalid to call this method with the visited class name as argument.
*
* @param nestMember the internal name of a nest member.
* @param nestMember the internal name of a nest member (see {@link Type#getInternalName()}).
*/
public void visitNestMember(final String nestMember) {
if (api < Opcodes.ASM7) {
Expand All @@ -286,7 +301,8 @@ public void visitNestMember(final String nestMember) {
* Visits a permitted subclasses. A permitted subclass is one of the allowed subclasses of the
* current class.
*
* @param permittedSubclass the internal name of a permitted subclass.
* @param permittedSubclass the internal name of a permitted subclass (see {@link
* Type#getInternalName()}).
*/
public void visitPermittedSubclass(final String permittedSubclass) {
if (api < Opcodes.ASM9) {
Expand All @@ -299,15 +315,18 @@ public void visitPermittedSubclass(final String permittedSubclass) {

/**
* Visits information about an inner class. This inner class is not necessarily a member of the
* class being visited.
* class being visited. More precisely, every class or interface C which is referenced by this
* class and which is not a package member must be visited with this method. This class must
* reference its nested class or interface members, and its enclosing class, if any. See the JVMS
* 4.7.6 section for more details.
*
* @param name the internal name of an inner class (see {@link Type#getInternalName()}).
* @param outerName the internal name of the class to which the inner class belongs (see {@link
* Type#getInternalName()}). May be {@literal null} for not member classes.
* @param innerName the (simple) name of the inner class inside its enclosing class. May be
* {@literal null} for anonymous inner classes.
* @param access the access flags of the inner class as originally declared in the enclosing
* class.
* @param name the internal name of C (see {@link Type#getInternalName()}).
* @param outerName the internal name of the class or interface C is a member of (see {@link
* Type#getInternalName()}). Must be {@literal null} if C is not the member of a class or
* interface (e.g. for local or anonymous classes).
* @param innerName the (simple) name of C. Must be {@literal null} for anonymous inner classes.
* @param access the access flags of C originally declared in the source code from which this
* class was compiled.
*/
public void visitInnerClass(
final String name, final String outerName, final String innerName, final int access) {
Expand Down Expand Up @@ -405,4 +424,3 @@ public void visitEnd() {
}
}
}

Expand Up @@ -249,6 +249,7 @@ public class ClassWriter extends ClassVisitor {
/**
* Indicates what must be automatically computed in {@link MethodWriter}. Must be one of {@link
* MethodWriter#COMPUTE_NOTHING}, {@link MethodWriter#COMPUTE_MAX_STACK_AND_LOCAL}, {@link
* MethodWriter#COMPUTE_MAX_STACK_AND_LOCAL_FROM_FRAMES}, {@link
* MethodWriter#COMPUTE_INSERTED_FRAMES}, or {@link MethodWriter#COMPUTE_ALL_FRAMES}.
*/
private int compute;
Expand Down Expand Up @@ -874,7 +875,7 @@ public int newUTF8(final String value) {
* constant pool already contains a similar item. <i>This method is intended for {@link Attribute}
* sub classes, and is normally not needed by class generators or adapters.</i>
*
* @param value the internal name of the class.
* @param value the internal name of the class (see {@link Type#getInternalName()}).
* @return the index of a new or already existing class reference item.
*/
public int newClass(final String value) {
Expand Down Expand Up @@ -926,7 +927,8 @@ public int newPackage(final String packageName) {
* Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link
* Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL},
* {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}.
* @param owner the internal name of the field or method owner class.
* @param owner the internal name of the field or method owner class (see {@link
* Type#getInternalName()}).
* @param name the name of the field or method.
* @param descriptor the descriptor of the field or method.
* @return the index of a new or already existing method type reference item.
Expand All @@ -948,7 +950,8 @@ public int newHandle(
* Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link
* Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL},
* {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}.
* @param owner the internal name of the field or method owner class.
* @param owner the internal name of the field or method owner class (see {@link
* Type#getInternalName()}).
* @param name the name of the field or method.
* @param descriptor the descriptor of the field or method.
* @param isInterface true if the owner is an interface.
Expand Down Expand Up @@ -1010,7 +1013,7 @@ public int newInvokeDynamic(
* constant pool already contains a similar item. <i>This method is intended for {@link Attribute}
* sub classes, and is normally not needed by class generators or adapters.</i>
*
* @param owner the internal name of the field's owner class.
* @param owner the internal name of the field's owner class (see {@link Type#getInternalName()}).
* @param name the field's name.
* @param descriptor the field's descriptor.
* @return the index of a new or already existing field reference item.
Expand All @@ -1024,7 +1027,8 @@ public int newField(final String owner, final String name, final String descript
* constant pool already contains a similar item. <i>This method is intended for {@link Attribute}
* sub classes, and is normally not needed by class generators or adapters.</i>
*
* @param owner the internal name of the method's owner class.
* @param owner the internal name of the method's owner class (see {@link
* Type#getInternalName()}).
* @param name the method's name.
* @param descriptor the method's descriptor.
* @param isInterface {@literal true} if {@code owner} is an interface.
Expand Down Expand Up @@ -1060,9 +1064,10 @@ public int newNameType(final String name, final String descriptor) {
* currently being generated by this ClassWriter, which can of course not be loaded since it is
* under construction.
*
* @param type1 the internal name of a class.
* @param type2 the internal name of another class.
* @return the internal name of the common super class of the two given classes.
* @param type1 the internal name of a class (see {@link Type#getInternalName()}).
* @param type2 the internal name of another class (see {@link Type#getInternalName()}).
* @return the internal name of the common super class of the two given classes (see {@link
* Type#getInternalName()}).
*/
protected String getCommonSuperClass(final String type1, final String type2) {
ClassLoader classLoader = getClassLoader();
Expand Down Expand Up @@ -1105,4 +1110,3 @@ protected ClassLoader getClassLoader() {
return getClass().getClassLoader();
}
}

Expand Up @@ -208,4 +208,3 @@ public String toString() {
+ Arrays.toString(bootstrapMethodArguments);
}
}

Expand Up @@ -251,4 +251,3 @@ static void checkIsPreview(final InputStream classInputStream) {
}
}
}

Expand Up @@ -166,4 +166,3 @@ final class Context {
*/
Object[] currentFrameStackTypes;
}

Expand Up @@ -85,4 +85,3 @@ void execute(
copyFrom(successor);
}
}

Expand Up @@ -121,4 +121,3 @@ final class Edge {
this.nextEdge = nextEdge;
}
}

Expand Up @@ -108,6 +108,15 @@ protected FieldVisitor(final int api, final FieldVisitor fieldVisitor) {
this.fv = fieldVisitor;
}

/**
* The field visitor to which this visitor must delegate method calls. May be {@literal null}.
*
* @return the field visitor to which this visitor must delegate method calls, or {@literal null}.
*/
public FieldVisitor getDelegate() {
return fv;
}

/**
* Visits an annotation of the field.
*
Expand Down Expand Up @@ -168,4 +177,3 @@ public void visitEnd() {
}
}
}

Expand Up @@ -314,4 +314,3 @@ final void collectAttributePrototypes(final Attribute.Set attributePrototypes) {
attributePrototypes.addAttributes(firstAttribute);
}
}

1 comment on commit 91d8ea7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.