[Git][java-team/asm][master] 7 commits: Standards-Version updated to 4.6.0.1
Emmanuel Bourg (@ebourg)
gitlab at salsa.debian.org
Sat Sep 18 08:56:35 BST 2021
Emmanuel Bourg pushed to branch master at Debian Java Maintainers / asm
Commits:
d6c3f0e8 by Emmanuel Bourg at 2021-09-18T09:29:16+02:00
Standards-Version updated to 4.6.0.1
- - - - -
a2ad6ddc by Emmanuel Bourg at 2021-09-18T09:29:30+02:00
Switch to debhelper level 13
- - - - -
a390cb5b by Emmanuel Bourg at 2021-09-18T09:30:05+02:00
New upstream version 9.2
- - - - -
ea4245ac by Emmanuel Bourg at 2021-09-18T09:30:06+02:00
Update upstream source from tag 'upstream/9.2'
Update to upstream version '9.2'
with Debian dir 602db90a525e8d0a4f1b25ec08e7d2d3113584b8
- - - - -
3b78ec7c by Emmanuel Bourg at 2021-09-18T09:52:17+02:00
Refreshed the patches
- - - - -
a5ef1a29 by Emmanuel Bourg at 2021-09-18T09:55:54+02:00
Revert back to debhelper level 12 (module exclusion is broken with DH 13, why?)
- - - - -
0a6ce47f by Emmanuel Bourg at 2021-09-18T09:56:03+02:00
Upload to unstable
- - - - -
16 changed files:
- asm-commons/src/main/java/org/objectweb/asm/commons/ModuleHashesAttribute.java
- asm-tree/src/main/java/org/objectweb/asm/tree/LdcInsnNode.java
- asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java
- asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java
- asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java
- asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java
- asm/src/main/java/org/objectweb/asm/ClassReader.java
- asm/src/main/java/org/objectweb/asm/ClassVisitor.java
- asm/src/main/java/org/objectweb/asm/ClassWriter.java
- asm/src/main/java/org/objectweb/asm/Opcodes.java
- asm/src/test/java/org/objectweb/asm/ConstantsTest.java
- build.gradle
- debian/changelog
- debian/control
- debian/patches/05-junit-compatibility.patch
- debian/patches/09-ignore-test-coverage.patch
Changes:
=====================================
asm-commons/src/main/java/org/objectweb/asm/commons/ModuleHashesAttribute.java
=====================================
@@ -103,7 +103,7 @@ public final class ModuleHashesAttribute extends Attribute {
currentOffset += 2;
byte[] hash = new byte[hashLength];
for (int j = 0; j < hashLength; ++j) {
- hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF);
+ hash[j] = (byte) classReader.readByte(currentOffset);
currentOffset += 1;
}
hashList.add(hash);
=====================================
asm-tree/src/main/java/org/objectweb/asm/tree/LdcInsnNode.java
=====================================
@@ -28,8 +28,11 @@
package org.objectweb.asm.tree;
import java.util.Map;
+import org.objectweb.asm.ConstantDynamic;
+import org.objectweb.asm.Handle;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
/**
* A node that represents an LDC instruction.
@@ -39,17 +42,23 @@ import org.objectweb.asm.Opcodes;
public class LdcInsnNode extends AbstractInsnNode {
/**
- * The constant to be loaded on the stack. This parameter must be a non null {@link Integer}, a
- * {@link Float}, a {@link Long}, a {@link Double}, a {@link String} or a {@link
- * org.objectweb.asm.Type}.
+ * The constant to be loaded on the stack. This field must be a non null {@link Integer}, a {@link
+ * Float}, a {@link Long}, a {@link Double}, a {@link String}, a {@link Type} of OBJECT or ARRAY
+ * sort for {@code .class} constants, for classes whose version is 49, a {@link Type} of METHOD
+ * sort for MethodType, a {@link Handle} for MethodHandle constants, for classes whose version is
+ * 51 or a {@link ConstantDynamic} for a constant dynamic for classes whose version is 55.
*/
public Object cst;
/**
* Constructs a new {@link LdcInsnNode}.
*
- * @param value the constant to be loaded on the stack. This parameter must be a non null {@link
- * Integer}, a {@link Float}, a {@link Long}, a {@link Double} or a {@link String}.
+ * @param value the constant to be loaded on the stack. This parameter mist be a non null {@link
+ * Integer}, a {@link Float}, a {@link Long}, a {@link Double}, a {@link String}, a {@link
+ * Type} of OBJECT or ARRAY sort for {@code .class} constants, for classes whose version is
+ * 49, a {@link Type} of METHOD sort for MethodType, a {@link Handle} for MethodHandle
+ * constants, for classes whose version is 51 or a {@link ConstantDynamic} for a constant
+ * dynamic for classes whose version is 55.
*/
public LdcInsnNode(final Object value) {
super(Opcodes.LDC);
=====================================
asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java
=====================================
@@ -107,6 +107,7 @@ public class ASMifier extends Printer {
classVersions.put(Opcodes.V15, "V15");
classVersions.put(Opcodes.V16, "V16");
classVersions.put(Opcodes.V17, "V17");
+ classVersions.put(Opcodes.V18, "V18");
CLASS_VERSIONS = Collections.unmodifiableMap(classVersions);
}
=====================================
asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java
=====================================
@@ -430,7 +430,8 @@ public class CheckClassAdapter extends ClassVisitor {
final String signature,
final String[] exceptions) {
checkState();
- checkAccess(
+ checkMethodAccess(
+ version,
access,
Opcodes.ACC_PUBLIC
| Opcodes.ACC_PRIVATE
@@ -555,6 +556,23 @@ public class CheckClassAdapter extends ClassVisitor {
}
}
+ /**
+ * Checks that the given access flags do not contain invalid flags for a method. This method also
+ * checks that mutually incompatible flags are not set simultaneously.
+ *
+ * @param version the class version.
+ * @param access the method access flags to be checked.
+ * @param possibleAccess the valid access flags.
+ */
+ private static void checkMethodAccess(
+ final int version, final int access, final int possibleAccess) {
+ checkAccess(access, possibleAccess);
+ if ((version & 0xFFFF) < Opcodes.V17
+ && Integer.bitCount(access & (Opcodes.ACC_STRICT | Opcodes.ACC_ABSTRACT)) > 1) {
+ throw new IllegalArgumentException("strictfp and abstract are mutually exclusive: " + access);
+ }
+ }
+
/**
* Checks that the given name is a fully qualified name, using dots.
*
@@ -1114,7 +1132,11 @@ public class CheckClassAdapter extends ClassVisitor {
if (name.charAt(endIndex - 1) == ';') {
endIndex--;
}
- return name.substring(lastSlashIndex + 1, endIndex);
+ int lastBracketIndex = name.lastIndexOf('[');
+ if (lastBracketIndex == -1) {
+ return name.substring(lastSlashIndex + 1, endIndex);
+ }
+ return name.substring(0, lastBracketIndex + 1) + name.substring(lastSlashIndex + 1, endIndex);
}
}
}
=====================================
asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java
=====================================
@@ -484,7 +484,7 @@ public class CheckMethodAdapter extends MethodVisitor {
checkUnqualifiedName(version, name, "name");
}
CheckClassAdapter.checkAccess(
- access, Opcodes.ACC_FINAL + Opcodes.ACC_MANDATED + Opcodes.ACC_SYNTHETIC);
+ access, Opcodes.ACC_FINAL | Opcodes.ACC_MANDATED | Opcodes.ACC_SYNTHETIC);
super.visitParameter(name, access);
}
=====================================
asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java
=====================================
@@ -360,6 +360,30 @@ public class CheckClassAdapterTest extends AsmTest implements Opcodes {
assertEquals("LC;I: error at index 3", exception.getMessage());
}
+ @Test
+ public void testVisitMethod_illegalAccessFlagSet() {
+ CheckClassAdapter checkClassAdapter = new CheckClassAdapter(null);
+ checkClassAdapter.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
+
+ Executable visitMethod =
+ () -> checkClassAdapter.visitMethod(ACC_ABSTRACT | ACC_STRICT, "m", "()V", null, null);
+
+ Exception exception = assertThrows(IllegalArgumentException.class, visitMethod);
+ assertEquals("strictfp and abstract are mutually exclusive: 3072", exception.getMessage());
+ }
+
+ @Test
+ public void testVisitMethod_legalAccessFlagSet_V17() {
+ // Java 17 allows to mix ACC_ABSTRACT and ACC_STRICT because ACC_STRICT is ignored
+ CheckClassAdapter checkClassAdapter = new CheckClassAdapter(null);
+ checkClassAdapter.visit(V17, ACC_PUBLIC, "C", null, "java/lang/Object", null);
+
+ Executable visitMethod =
+ () -> checkClassAdapter.visitMethod(ACC_ABSTRACT | ACC_STRICT, "m", "()V", null, null);
+
+ assertDoesNotThrow(visitMethod);
+ }
+
@Test
public void testVisitMethod_illegalSignature() {
CheckClassAdapter checkClassAdapter = new CheckClassAdapter(null);
@@ -549,6 +573,7 @@ public class CheckClassAdapterTest extends AsmTest implements Opcodes {
String log = logger.toString();
assertFalse(log.startsWith(AnalyzerException.class.getName() + ": Error at instruction"));
assertTrue(log.contains("00000 CheckClassAdapterTest : : ALOAD 0"));
+ assertTrue(log.contains("00001 CheckClassAdapterTest [Object : [Object : ARETURN"));
}
@Test
@@ -578,4 +603,8 @@ public class CheckClassAdapterTest extends AsmTest implements Opcodes {
private static Attribute[] attributes() {
return new Attribute[] {new Comment(), new CodeComment()};
}
+
+ Object methodWithObjectArrayArgument(final Object[] arg) {
+ return arg;
+ }
}
=====================================
asm/src/main/java/org/objectweb/asm/ClassReader.java
=====================================
@@ -88,6 +88,9 @@ public class ClassReader {
*/
static final int EXPAND_ASM_INSNS = 256;
+ /** The maximum size of array to allocate. */
+ private static final int MAX_BUFFER_SIZE = 1024 * 1024;
+
/** The size of the temporary byte array used to read class input streams chunk by chunk. */
private static final int INPUT_STREAM_DATA_CHUNK_SIZE = 4096;
@@ -191,7 +194,7 @@ public class 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.V17) {
+ if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V18) {
throw new IllegalArgumentException(
"Unsupported class file major version " + readShort(classFileOffset + 6));
}
@@ -310,13 +313,19 @@ public class ClassReader {
if (inputStream == null) {
throw new IOException("Class not found");
}
+ int bufferSize = calculateBufferSize(inputStream);
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
- byte[] data = new byte[INPUT_STREAM_DATA_CHUNK_SIZE];
+ byte[] data = new byte[bufferSize];
int bytesRead;
- while ((bytesRead = inputStream.read(data, 0, data.length)) != -1) {
+ int readCount = 0;
+ while ((bytesRead = inputStream.read(data, 0, bufferSize)) != -1) {
outputStream.write(data, 0, bytesRead);
+ readCount++;
}
outputStream.flush();
+ if (readCount == 1) {
+ return data;
+ }
return outputStream.toByteArray();
} finally {
if (close) {
@@ -325,6 +334,20 @@ public class ClassReader {
}
}
+ private static int calculateBufferSize(final InputStream inputStream) throws IOException {
+ int expectedLength = inputStream.available();
+ /*
+ * Some implementations can return 0 while holding available data
+ * (e.g. new FileInputStream("/proc/a_file"))
+ * Also in some pathological cases a very small number might be returned,
+ * and in this case we use default size
+ */
+ if (expectedLength < 256) {
+ return INPUT_STREAM_DATA_CHUNK_SIZE;
+ }
+ return Math.min(expectedLength, MAX_BUFFER_SIZE);
+ }
+
// -----------------------------------------------------------------------------------------------
// Accessors
// -----------------------------------------------------------------------------------------------
=====================================
asm/src/main/java/org/objectweb/asm/ClassVisitor.java
=====================================
@@ -30,8 +30,8 @@ package org.objectweb.asm;
/**
* A visitor to visit a Java class. The methods of this class must be called in the following order:
* {@code visit} [ {@code visitSource} ] [ {@code visitModule} ][ {@code visitNestHost} ][ {@code
- * visitPermittedSubclass} ][ {@code visitOuterClass} ] ( {@code visitAnnotation} | {@code
- * visitTypeAnnotation} | {@code visitAttribute} )* ( {@code visitNestMember} | {@code
+ * visitOuterClass} ] ( {@code visitAnnotation} | {@code visitTypeAnnotation} | {@code
+ * visitAttribute} )* ( {@code visitNestMember} | [ {@code * visitPermittedSubclass} ] | {@code
* visitInnerClass} | {@code visitRecordComponent} | {@code visitField} | {@code visitMethod} )*
* {@code visitEnd}.
*
=====================================
asm/src/main/java/org/objectweb/asm/ClassWriter.java
=====================================
@@ -79,7 +79,7 @@ public class ClassWriter extends ClassVisitor {
/**
* The access_flags field of the JVMS ClassFile structure. This field can contain ASM specific
- * access flags, such as {@link Opcodes#ACC_DEPRECATED} or {}@link Opcodes#ACC_RECORD}, which are
+ * access flags, such as {@link Opcodes#ACC_DEPRECATED} or {@link Opcodes#ACC_RECORD}, which are
* removed when generating the ClassFile structure.
*/
private int accessFlags;
=====================================
asm/src/main/java/org/objectweb/asm/Opcodes.java
=====================================
@@ -283,6 +283,7 @@ public interface Opcodes {
int V15 = 0 << 16 | 59;
int V16 = 0 << 16 | 60;
int V17 = 0 << 16 | 61;
+ int V18 = 0 << 16 | 62;
/**
* Version flag indicating that the class is using 'preview' features.
=====================================
asm/src/test/java/org/objectweb/asm/ConstantsTest.java
=====================================
@@ -250,6 +250,7 @@ public class ConstantsTest {
case "V15":
case "V16":
case "V17":
+ case "V18":
return ConstantType.CLASS_VERSION;
case "ACC_PUBLIC":
case "ACC_PRIVATE":
=====================================
build.gradle
=====================================
@@ -44,7 +44,7 @@ subprojects {
apply plugin: 'jacoco'
def snapshotSuffix = rootProject.hasProperty('release') ? '' : '-SNAPSHOT'
group = 'org.ow2.asm'
- version = '9.1' + snapshotSuffix
+ version = '9.2' + snapshotSuffix
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
test { useJUnitPlatform() }
@@ -209,7 +209,7 @@ subprojects {
// and uploaded to Maven with a POM, sources and Javadoc.
configure(subprojects.findAll { it.provides }) {
// Code coverage configuration.
- jacoco.toolVersion = '0.8.6'
+ jacoco.toolVersion = '0.8.7'
jacocoTestReport {
reports { xml.enabled true }
classDirectories.setFrom(sourceSets.main.output.classesDirs)
=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+asm (9.2-1) unstable; urgency=medium
+
+ * New upstream release
+ - Refreshed the patches
+ * Standards-Version updated to 4.6.0.1
+
+ -- Emmanuel Bourg <ebourg at apache.org> Sat, 18 Sep 2021 09:55:58 +0200
+
asm (9.1-1) unstable; urgency=medium
* New upstream release
=====================================
debian/control
=====================================
@@ -13,7 +13,7 @@ Build-Depends:
gradle-debian-helper (>= 2.0),
gradle (>= 4.4),
maven-repo-helper
-Standards-Version: 4.5.1
+Standards-Version: 4.6.0.1
Vcs-Git: https://salsa.debian.org/java-team/asm.git
Vcs-Browser: https://salsa.debian.org/java-team/asm
Homepage: http://asm.ow2.io
=====================================
debian/patches/05-junit-compatibility.patch
=====================================
@@ -4,7 +4,7 @@ Forwarded: not-needed
--- a/build.gradle
+++ b/build.gradle
@@ -47,7 +47,6 @@
- version = '9.1' + snapshotSuffix
+ version = '9.2' + snapshotSuffix
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
- test { useJUnitPlatform() }
=====================================
debian/patches/09-ignore-test-coverage.patch
=====================================
@@ -8,7 +8,7 @@ Forwarded: not-needed
// and uploaded to Maven with a POM, sources and Javadoc.
configure(subprojects.findAll { it.provides }) {
- // Code coverage configuration.
-- jacoco.toolVersion = '0.8.6'
+- jacoco.toolVersion = '0.8.7'
- jacocoTestReport {
- reports { xml.enabled true }
- classDirectories.setFrom(sourceSets.main.output.classesDirs)
View it on GitLab: https://salsa.debian.org/java-team/asm/-/compare/004e458a5756d5def8a31d90e7578f9e1cfe3239...0a6ce47f09337df9db883f675253fb8130e17d16
--
View it on GitLab: https://salsa.debian.org/java-team/asm/-/compare/004e458a5756d5def8a31d90e7578f9e1cfe3239...0a6ce47f09337df9db883f675253fb8130e17d16
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20210918/9494d803/attachment.htm>
More information about the pkg-java-commits
mailing list