From d76a242e825687f28155991e825e182d3747e83f Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 17 May 2024 13:41:37 +0200 Subject: [PATCH 1/2] (deps): Update to ASM 9.7 --- .../sisu/space/asm/AnnotationWriter.java | 8 +- .../eclipse/sisu/space/asm/ClassReader.java | 109 +++++++++--------- .../eclipse/sisu/space/asm/ClassWriter.java | 2 +- .../eclipse/sisu/space/asm/MethodWriter.java | 8 +- .../org/eclipse/sisu/space/asm/Opcodes.java | 1 + .../eclipse/sisu/space/asm/SymbolTable.java | 8 +- 6 files changed, 67 insertions(+), 69 deletions(-) diff --git a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/AnnotationWriter.java b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/AnnotationWriter.java index cb7b1792..992141f1 100644 --- a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/AnnotationWriter.java +++ b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/AnnotationWriter.java @@ -144,7 +144,7 @@ static AnnotationWriter create( // Write type_index and reserve space for num_element_value_pairs. annotation.putShort(symbolTable.addConstantUtf8(descriptor)).putShort(0); return new AnnotationWriter( - symbolTable, /* useNamedValues = */ true, annotation, previousAnnotation); + symbolTable, /* useNamedValues= */ true, annotation, previousAnnotation); } /** @@ -179,7 +179,7 @@ static AnnotationWriter create( // Write type_index and reserve space for num_element_value_pairs. typeAnnotation.putShort(symbolTable.addConstantUtf8(descriptor)).putShort(0); return new AnnotationWriter( - symbolTable, /* useNamedValues = */ true, typeAnnotation, previousAnnotation); + symbolTable, /* useNamedValues= */ true, typeAnnotation, previousAnnotation); } // ----------------------------------------------------------------------------------------------- @@ -284,7 +284,7 @@ public AnnotationVisitor visitAnnotation(final String name, final String descrip } // Write tag and type_index, and reserve 2 bytes for num_element_value_pairs. annotation.put12('@', symbolTable.addConstantUtf8(descriptor)).putShort(0); - return new AnnotationWriter(symbolTable, /* useNamedValues = */ true, annotation, null); + return new AnnotationWriter(symbolTable, /* useNamedValues= */ true, annotation, null); } @Override @@ -303,7 +303,7 @@ public AnnotationVisitor visitArray(final String name) { // visit the array elements. Its num_element_value_pairs will correspond to the number of array // elements and will be stored in what is in fact num_values. annotation.put12('[', 0); - return new AnnotationWriter(symbolTable, /* useNamedValues = */ false, annotation, null); + return new AnnotationWriter(symbolTable, /* useNamedValues= */ false, annotation, null); } @Override diff --git a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/ClassReader.java b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/ClassReader.java index df770d38..ad9bfab3 100644 --- a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/ClassReader.java +++ b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/ClassReader.java @@ -177,7 +177,7 @@ public ClassReader( final byte[] classFileBuffer, final int classFileOffset, final int classFileLength) { // NOPMD(UnusedFormalParameter) used for backward compatibility. - this(classFileBuffer, classFileOffset, /* checkClassVersion = */ true); + this(classFileBuffer, classFileOffset, /* checkClassVersion= */ true); } /** @@ -195,7 +195,7 @@ 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.V22) { + if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V23) { throw new IllegalArgumentException( "Unsupported class file major version " + readShort(classFileOffset + 6)); } @@ -607,9 +607,9 @@ public void accept( // Parse num_element_value_pairs and element_value_pairs and visit these values. currentAnnotationOffset = readElementValues( - classVisitor.visitAnnotation(annotationDescriptor, /* visible = */ true), + classVisitor.visitAnnotation(annotationDescriptor, /* visible= */ true), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -625,9 +625,9 @@ public void accept( // Parse num_element_value_pairs and element_value_pairs and visit these values. currentAnnotationOffset = readElementValues( - classVisitor.visitAnnotation(annotationDescriptor, /* visible = */ false), + classVisitor.visitAnnotation(annotationDescriptor, /* visible= */ false), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -649,9 +649,9 @@ public void accept( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ true), + /* visible= */ true), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -673,9 +673,9 @@ public void accept( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ false), + /* visible= */ false), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -967,9 +967,9 @@ private int readRecordComponent( // Parse num_element_value_pairs and element_value_pairs and visit these values. currentAnnotationOffset = readElementValues( - recordComponentVisitor.visitAnnotation(annotationDescriptor, /* visible = */ true), + recordComponentVisitor.visitAnnotation(annotationDescriptor, /* visible= */ true), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -985,9 +985,9 @@ private int readRecordComponent( // Parse num_element_value_pairs and element_value_pairs and visit these values. currentAnnotationOffset = readElementValues( - recordComponentVisitor.visitAnnotation(annotationDescriptor, /* visible = */ false), + recordComponentVisitor.visitAnnotation(annotationDescriptor, /* visible= */ false), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1009,9 +1009,9 @@ private int readRecordComponent( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ true), + /* visible= */ true), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1033,9 +1033,9 @@ private int readRecordComponent( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ false), + /* visible= */ false), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1151,9 +1151,9 @@ private int readField( // Parse num_element_value_pairs and element_value_pairs and visit these values. currentAnnotationOffset = readElementValues( - fieldVisitor.visitAnnotation(annotationDescriptor, /* visible = */ true), + fieldVisitor.visitAnnotation(annotationDescriptor, /* visible= */ true), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1169,9 +1169,9 @@ private int readField( // Parse num_element_value_pairs and element_value_pairs and visit these values. currentAnnotationOffset = readElementValues( - fieldVisitor.visitAnnotation(annotationDescriptor, /* visible = */ false), + fieldVisitor.visitAnnotation(annotationDescriptor, /* visible= */ false), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1193,9 +1193,9 @@ private int readField( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ true), + /* visible= */ true), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1217,9 +1217,9 @@ private int readField( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ false), + /* visible= */ false), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1412,9 +1412,9 @@ private int readMethod( // Parse num_element_value_pairs and element_value_pairs and visit these values. currentAnnotationOffset = readElementValues( - methodVisitor.visitAnnotation(annotationDescriptor, /* visible = */ true), + methodVisitor.visitAnnotation(annotationDescriptor, /* visible= */ true), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1430,9 +1430,9 @@ private int readMethod( // Parse num_element_value_pairs and element_value_pairs and visit these values. currentAnnotationOffset = readElementValues( - methodVisitor.visitAnnotation(annotationDescriptor, /* visible = */ false), + methodVisitor.visitAnnotation(annotationDescriptor, /* visible= */ false), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1454,9 +1454,9 @@ private int readMethod( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ true), + /* visible= */ true), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1478,9 +1478,9 @@ private int readMethod( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ false), + /* visible= */ false), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -1488,16 +1488,13 @@ private int readMethod( // Visit the RuntimeVisibleParameterAnnotations attribute. if (runtimeVisibleParameterAnnotationsOffset != 0) { readParameterAnnotations( - methodVisitor, context, runtimeVisibleParameterAnnotationsOffset, /* visible = */ true); + methodVisitor, context, runtimeVisibleParameterAnnotationsOffset, /* visible= */ true); } // Visit the RuntimeInvisibleParameterAnnotations attribute. if (runtimeInvisibleParameterAnnotationsOffset != 0) { readParameterAnnotations( - methodVisitor, - context, - runtimeInvisibleParameterAnnotationsOffset, - /* visible = */ false); + methodVisitor, context, runtimeInvisibleParameterAnnotationsOffset, /* visible= */ false); } // Visit the non standard attributes. @@ -1926,7 +1923,7 @@ private void readCode( } } else if (Constants.RUNTIME_VISIBLE_TYPE_ANNOTATIONS.equals(attributeName)) { visibleTypeAnnotationOffsets = - readTypeAnnotations(methodVisitor, context, currentOffset, /* visible = */ true); + readTypeAnnotations(methodVisitor, context, currentOffset, /* visible= */ true); // Here we do not extract the labels corresponding to the attribute content. This would // require a full parsing of the attribute, which would need to be repeated when parsing // the bytecode instructions (see below). Instead, the content of the attribute is read one @@ -1935,7 +1932,7 @@ private void readCode( // time. This assumes that type annotations are ordered by increasing bytecode offset. } else if (Constants.RUNTIME_INVISIBLE_TYPE_ANNOTATIONS.equals(attributeName)) { invisibleTypeAnnotationOffsets = - readTypeAnnotations(methodVisitor, context, currentOffset, /* visible = */ false); + readTypeAnnotations(methodVisitor, context, currentOffset, /* visible= */ false); // Same comment as above for the RuntimeVisibleTypeAnnotations attribute. } else if (Constants.STACK_MAP_TABLE.equals(attributeName)) { if ((context.parsingOptions & SKIP_FRAMES) == 0) { @@ -2517,9 +2514,9 @@ private void readCode( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ true), + /* visible= */ true), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } currentVisibleTypeAnnotationBytecodeOffset = @@ -2545,9 +2542,9 @@ private void readCode( context.currentTypeAnnotationTarget, context.currentTypeAnnotationTargetPath, annotationDescriptor, - /* visible = */ false), + /* visible= */ false), currentAnnotationOffset, - /* named = */ true, + /* named= */ true, charBuffer); } currentInvisibleTypeAnnotationBytecodeOffset = @@ -2618,9 +2615,9 @@ private void readCode( context.currentLocalVariableAnnotationRangeEnds, context.currentLocalVariableAnnotationRangeIndices, annotationDescriptor, - /* visible = */ true), + /* visible= */ true), currentOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -2646,9 +2643,9 @@ private void readCode( context.currentLocalVariableAnnotationRangeEnds, context.currentLocalVariableAnnotationRangeIndices, annotationDescriptor, - /* visible = */ false), + /* visible= */ false), currentOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -2821,7 +2818,7 @@ private int[] readTypeAnnotations( methodVisitor.visitTryCatchAnnotation( targetType & 0xFFFFFF00, path, annotationDescriptor, visible), currentOffset, - /* named = */ true, + /* named= */ true, charBuffer); } else { // We don't want to visit the other target_type annotations, so we just skip them (which @@ -2832,7 +2829,7 @@ private int[] readTypeAnnotations( // with a null AnnotationVisitor). currentOffset = readElementValues( - /* annotationVisitor = */ null, currentOffset, /* named = */ true, charBuffer); + /* annotationVisitor= */ null, currentOffset, /* named= */ true, charBuffer); } } return typeAnnotationsOffsets; @@ -2972,7 +2969,7 @@ private void readParameterAnnotations( readElementValues( methodVisitor.visitParameterAnnotation(i, annotationDescriptor, visible), currentOffset, - /* named = */ true, + /* named= */ true, charBuffer); } } @@ -3042,9 +3039,9 @@ private int readElementValue( case 'e': // enum_const_value return currentOffset + 5; case '@': // annotation_value - return readElementValues(null, currentOffset + 3, /* named = */ true, charBuffer); + return readElementValues(null, currentOffset + 3, /* named= */ true, charBuffer); case '[': // array_value - return readElementValues(null, currentOffset + 1, /* named = */ false, charBuffer); + return readElementValues(null, currentOffset + 1, /* named= */ false, charBuffer); default: return currentOffset + 3; } @@ -3112,7 +3109,7 @@ private int readElementValue( return readElementValues( annotationVisitor.visitArray(elementName), currentOffset - 2, - /* named = */ false, + /* named= */ false, charBuffer); } switch (classFileBuffer[currentOffset] & 0xFF) { @@ -3189,7 +3186,7 @@ private int readElementValue( readElementValues( annotationVisitor.visitArray(elementName), currentOffset - 2, - /* named = */ false, + /* named= */ false, charBuffer); break; } diff --git a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/ClassWriter.java b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/ClassWriter.java index c173b3ae..1803fa85 100644 --- a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/ClassWriter.java +++ b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/ClassWriter.java @@ -774,7 +774,7 @@ private byte[] replaceAsmInstructions(final byte[] classFile, final boolean hasF lastRecordComponent = null; firstAttribute = null; compute = hasFrames ? MethodWriter.COMPUTE_INSERTED_FRAMES : MethodWriter.COMPUTE_NOTHING; - new ClassReader(classFile, 0, /* checkClassVersion = */ false) + new ClassReader(classFile, 0, /* checkClassVersion= */ false) .accept( this, attributes, diff --git a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/MethodWriter.java b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/MethodWriter.java index 523bace1..0479c1ed 100644 --- a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/MethodWriter.java +++ b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/MethodWriter.java @@ -651,7 +651,7 @@ public void visitParameter(final String name, final int access) { @Override public AnnotationVisitor visitAnnotationDefault() { defaultValue = new ByteVector(); - return new AnnotationWriter(symbolTable, /* useNamedValues = */ false, defaultValue, null); + return new AnnotationWriter(symbolTable, /* useNamedValues= */ false, defaultValue, null); } @Override @@ -1519,14 +1519,14 @@ public AnnotationVisitor visitLocalVariableAnnotation( return lastCodeRuntimeVisibleTypeAnnotation = new AnnotationWriter( symbolTable, - /* useNamedValues = */ true, + /* useNamedValues= */ true, typeAnnotation, lastCodeRuntimeVisibleTypeAnnotation); } else { return lastCodeRuntimeInvisibleTypeAnnotation = new AnnotationWriter( symbolTable, - /* useNamedValues = */ true, + /* useNamedValues= */ true, typeAnnotation, lastCodeRuntimeInvisibleTypeAnnotation); } @@ -1642,7 +1642,7 @@ private void computeAllFrames() { code.data[endOffset] = (byte) Opcodes.ATHROW; // Emit a frame for this unreachable block, with no local and a Throwable on the stack // (so that the ATHROW could consume this Throwable if it were reachable). - int frameIndex = visitFrameStart(startOffset, /* numLocal = */ 0, /* numStack = */ 1); + int frameIndex = visitFrameStart(startOffset, /* numLocal= */ 0, /* numStack= */ 1); currentFrame[frameIndex] = Frame.getAbstractTypeFromInternalName(symbolTable, "java/lang/Throwable"); visitFrameEnd(); diff --git a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/Opcodes.java b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/Opcodes.java index 9ce86b6f..df3cc1a9 100644 --- a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/Opcodes.java +++ b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/Opcodes.java @@ -288,6 +288,7 @@ public interface Opcodes { int V20 = 0 << 16 | 64; int V21 = 0 << 16 | 65; int V22 = 0 << 16 | 66; + int V23 = 0 << 16 | 67; /** * Version flag indicating that the class is using 'preview' features. diff --git a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/SymbolTable.java b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/SymbolTable.java index 0d71aeea..83b3521b 100644 --- a/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/SymbolTable.java +++ b/org.eclipse.sisu.inject/src/main/java/org/eclipse/sisu/space/asm/SymbolTable.java @@ -1414,23 +1414,23 @@ private static final class Entry extends Symbol { } Entry(final int index, final int tag, final String value, final int hashCode) { - super(index, tag, /* owner = */ null, /* name = */ null, value, /* data = */ 0); + super(index, tag, /* owner= */ null, /* name= */ null, value, /* data= */ 0); this.hashCode = hashCode; } Entry(final int index, final int tag, final String value, final long data, final int hashCode) { - super(index, tag, /* owner = */ null, /* name = */ null, value, data); + super(index, tag, /* owner= */ null, /* name= */ null, value, data); this.hashCode = hashCode; } Entry( final int index, final int tag, final String name, final String value, final int hashCode) { - super(index, tag, /* owner = */ null, name, value, /* data = */ 0); + super(index, tag, /* owner= */ null, name, value, /* data= */ 0); this.hashCode = hashCode; } Entry(final int index, final int tag, final long data, final int hashCode) { - super(index, tag, /* owner = */ null, /* name = */ null, /* value = */ null, data); + super(index, tag, /* owner= */ null, /* name= */ null, /* value= */ null, data); this.hashCode = hashCode; } } From a414f62730cdf2313b1233cc3f23d620c9a84332 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 17 May 2024 13:45:53 +0200 Subject: [PATCH 2/2] Align UT used asm with included one --- org.eclipse.sisu.inject/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.eclipse.sisu.inject/pom.xml b/org.eclipse.sisu.inject/pom.xml index 4c20e1ac..d5514940 100644 --- a/org.eclipse.sisu.inject/pom.xml +++ b/org.eclipse.sisu.inject/pom.xml @@ -192,7 +192,7 @@ org.ow2.asm asm - 9.5 + 9.7 cglib @@ -240,7 +240,7 @@ org.ow2.asm asm - 9.5 + 9.7 com.google.inject @@ -288,7 +288,7 @@ org.ow2.asm asm - 9.5 + 9.7 com.google.inject