Skip to content

Commit

Permalink
Adopt ASM 9.5
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <[email protected]>
  • Loading branch information
jansupol committed Apr 27, 2023
1 parent ad57277 commit f42459f
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ KineticJS, v4.7.1
* Project: http://www.kineticjs.com, https://github.com/ericdrowell/KineticJS
* Copyright: Eric Rowell

org.objectweb.asm Version 9.4
org.objectweb.asm Version 9.5
* License: Modified BSD (https://asm.ow2.io/license.html)
* Copyright (c) 2000-2011 INRIA, France Telecom. All rights reserved.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,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.V20) {
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V21) {
throw new IllegalArgumentException(
"Unsupported class file major version " + readShort(classFileOffset + 6));
}
Expand Down Expand Up @@ -2050,6 +2050,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 @@ -2665,6 +2666,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
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,12 @@ private static int getAbstractTypeFromDescriptor(
typeValue = REFERENCE_KIND | symbolTable.addType(internalName);
break;
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException(
"Invalid descriptor fragment: " + buffer.substring(elementDescriptorOffset));
}
return ((elementDescriptorOffset - offset) << DIM_SHIFT) | typeValue;
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException("Invalid descriptor: " + buffer.substring(offset));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public class Label {
/** A flag indicating that the basic block corresponding to a label is the end of a subroutine. */
static final int FLAG_SUBROUTINE_END = 64;

/** A flag indicating that this label has at least one associated line number. */
static final int FLAG_LINE_NUMBER = 128;

/**
* The number of elements to add to the {@link #otherLineNumbers} array when it needs to be
* resized to store a new source line number.
Expand Down Expand Up @@ -145,9 +148,9 @@ public class Label {
short flags;

/**
* The source line number corresponding to this label, or 0. If there are several source line
* numbers corresponding to this label, the first one is stored in this field, and the remaining
* ones are stored in {@link #otherLineNumbers}.
* The source line number corresponding to this label, if {@link #FLAG_LINE_NUMBER} is set. If
* there are several source line numbers corresponding to this label, the first one is stored in
* this field, and the remaining ones are stored in {@link #otherLineNumbers}.
*/
private short lineNumber;

Expand Down Expand Up @@ -332,7 +335,8 @@ final Label getCanonicalInstance() {
* @param lineNumber a source line number (which should be strictly positive).
*/
final void addLineNumber(final int lineNumber) {
if (this.lineNumber == 0) {
if ((flags & FLAG_LINE_NUMBER) == 0) {
flags |= FLAG_LINE_NUMBER;
this.lineNumber = (short) lineNumber;
} else {
if (otherLineNumbers == null) {
Expand All @@ -356,7 +360,7 @@ final void addLineNumber(final int lineNumber) {
*/
final void accept(final MethodVisitor methodVisitor, final boolean visitLineNumbers) {
methodVisitor.visitLabel(this);
if (visitLineNumbers && lineNumber != 0) {
if (visitLineNumbers && (flags & FLAG_LINE_NUMBER) != 0) {
methodVisitor.visitLineNumber(lineNumber & 0xFFFF, this);
if (otherLineNumbers != null) {
for (int i = 1; i <= otherLineNumbers[0]; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* A visitor to visit a Java method. The methods of this class must be called in the following
* order: ( {@code visitParameter} )* [ {@code visitAnnotationDefault} ] ( {@code visitAnnotation} |
* {@code visitAnnotableParameterCount} | {@code visitParameterAnnotation} {@code
* {@code visitAnnotableParameterCount} | {@code visitParameterAnnotation} | {@code
* visitTypeAnnotation} | {@code visitAttribute} )* [ {@code visitCode} ( {@code visitFrame} |
* {@code visit<i>X</i>Insn} | {@code visitLabel} | {@code visitInsnAnnotation} | {@code
* visitTryCatchBlock} | {@code visitTryCatchAnnotation} | {@code visitLocalVariable} | {@code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public interface Opcodes {
int V18 = 0 << 16 | 62;
int V19 = 0 << 16 | 63;
int V20 = 0 << 16 | 64;
int V21 = 0 << 16 | 65;

/**
* Version flag indicating that the class is using 'preview' features.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class RecordComponentWriter extends RecordComponentVisitor {
/** The name_index field of the Record attribute. */
private final int nameIndex;

/** The descriptor_index field of the the Record attribute. */
/** The descriptor_index field of the Record attribute. */
private final int descriptorIndex;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private Class getClassForName(final String className) {

private static class ClassReaderWrapper {
private static final Logger LOGGER = Logger.getLogger(ClassReader.class.getName());
private static final int WARN_VERSION = Opcodes.V20;
private static final int WARN_VERSION = Opcodes.V21;
private static final int INPUT_STREAM_DATA_CHUNK_SIZE = 4096;

private final byte[] b;
Expand Down
2 changes: 1 addition & 1 deletion core-server/src/main/resources/META-INF/NOTICE.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ org.glassfish.jersey.server.internal.monitoring.core
* Copyright (c) 2015-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2010-2013 Coda Hale and Yammer, Inc.

org.objectweb.asm Version 9.4
org.objectweb.asm Version 9.5
* License: Modified BSD (https://asm.ow2.io/license.html)
* Copyright: (c) 2000-2011 INRIA, France Telecom. All rights reserved.

Expand Down
2 changes: 1 addition & 1 deletion examples/NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ KineticJS, v4.7.1
* Project: http://www.kineticjs.com, https://github.com/ericdrowell/KineticJS
* Copyright: Eric Rowell

org.objectweb.asm Version 9.4
org.objectweb.asm Version 9.5
* License: Modified BSD (https://asm.ow2.io/license.html)
* Copyright (c) 2000-2011 INRIA, France Telecom. All rights reserved.

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@
<arquillian.weld.version>2.1.0.Final</arquillian.weld.version>
<!-- asm is now source integrated - keeping this property to see the version -->
<!-- see core-server/src/main/java/jersey/repackaged/asm/.. -->
<asm.version>9.4</asm.version>
<asm.version>9.5</asm.version>
<bnd.plugin.version>2.3.6</bnd.plugin.version>
<commons.io.version>2.11.0</commons.io.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
Expand Down

0 comments on commit f42459f

Please sign in to comment.