asm merge requestshttps://gitlab.ow2.org/asm/asm/-/merge_requests2018-05-14T14:35:20Zhttps://gitlab.ow2.org/asm/asm/-/merge_requests/175reformat the comments in Opcodes that i've butechered with the previous commit2018-05-14T14:35:20ZRemi Foraxreformat the comments in Opcodes that i've butechered with the previous commitcommitcommitRemi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/174recognize a preview features class (the class minor versopn should be V_PREVI...2018-05-14T14:07:49ZRemi Foraxrecognize a preview features class (the class minor versopn should be V_PREVIEW) and add a test classRecognize a 'preview features' class (the class minor versopn should be V_PREVIEW) and add a test classRecognize a 'preview features' class (the class minor versopn should be V_PREVIEW) and add a test classEric BrunetonEric Brunetonhttps://gitlab.ow2.org/asm/asm/-/merge_requests/173Resolve "Computing maximum stack size does not work correctly with dead code ...2022-03-15T16:00:28ZEric BrunetonResolve "Computing maximum stack size does not work correctly with dead code present"Closes #317827Closes #317827Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/172Add an experimental suffix to the new features (also mark them deprecated and…2018-05-02T19:32:29ZEric BrunetonAdd an experimental suffix to the new features (also mark them deprecated and…Add an experimental suffix to the new features (also mark them deprecated and show a big warning in the Javadoc). Revert to ASM6 for the default api of the visitors, and use ASM7_EXPERIMENTAL only in tests (only exception: Trace*Visitor ...Add an experimental suffix to the new features (also mark them deprecated and show a big warning in the Javadoc). Revert to ASM6 for the default api of the visitors, and use ASM7_EXPERIMENTAL only in tests (only exception: Trace*Visitor classes, which are final). This pattern could allow us to develop any new feature directly in 'master'.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/171Add an experimental suffix to the new features (also mark them deprecated and…2018-05-02T18:05:48ZEric BrunetonAdd an experimental suffix to the new features (also mark them deprecated and…Add an experimental suffix to the new features (also mark them deprecated and show a big warning in the Javadoc). Revert to ASM6 for the default api of the visitors, and use ASM7_EXPERIMENTAL only in tests (only exception: Trace*Visitor ...Add an experimental suffix to the new features (also mark them deprecated and show a big warning in the Javadoc). Revert to ASM6 for the default api of the visitors, and use ASM7_EXPERIMENTAL only in tests (only exception: Trace*Visitor classes, which are final). This pattern could allow us to develop any new feature directly in 'master'.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/170Resolve "ACC_SYNTHETIC attribute is still lost if constant pool is retained"2018-04-24T18:42:42ZEric BrunetonResolve "ACC_SYNTHETIC attribute is still lost if constant pool is retained"Closes #317825Closes #317825https://gitlab.ow2.org/asm/asm/-/merge_requests/169Improve the quality of the code related to ConstantDynamic.2018-05-01T19:15:57ZEric BrunetonImprove the quality of the code related to ConstantDynamic.Note: I'm not sure about the semantics of the ConstantDynamic name: ConstantDynamic says it can be arbitrary, but ChedkMethodAdapter checks that it is a method identifier?Note: I'm not sure about the semantics of the ConstantDynamic name: ConstantDynamic says it can be arbitrary, but ChedkMethodAdapter checks that it is a method identifier?Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/168Improve the quality of the code related to nest mates.2018-04-23T18:28:44ZEric BrunetonImprove the quality of the code related to nest mates.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/167Add a task to generate a sigtest file for the current version.2018-04-25T18:47:19ZEric BrunetonAdd a task to generate a sigtest file for the current version.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/166Resolve "Enhance ClassWriter to take a class loader for use with getCommonSup...2018-06-16T14:31:46ZmbensonResolve "Enhance ClassWriter to take a class loader for use with getCommonSuperClass"addresses #317609addresses #317609https://gitlab.ow2.org/asm/asm/-/merge_requests/165Add unit tests cases for ConstantDynamic and fix bugs found with them.2018-08-26T10:03:21ZEric BrunetonAdd unit tests cases for ConstantDynamic and fix bugs found with them.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/164Add unit test cases for nest mates, and fix a ClassWriter bug found with them.2018-04-22T17:11:09ZEric BrunetonAdd unit test cases for nest mates, and fix a ClassWriter bug found with them.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/163Resolve "Computing maximum stack size does not work correctly with JSR/RET in...2018-04-23T18:31:10ZEric BrunetonResolve "Computing maximum stack size does not work correctly with JSR/RET instructions present"Closes #317823Closes #317823Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/162Resolve "ACC_DEPRECATED flag (or corresponding attribute) is lost if the cons...2018-04-23T18:21:15ZEric BrunetonResolve "ACC_DEPRECATED flag (or corresponding attribute) is lost if the constant pool is copied"There is a generic way to implement the same thing, which would automatically ensure that this logic is always up to date:
```
boolean canCopyMethodAttributes(
final int access,
final String name,
final String descript...There is a generic way to implement the same thing, which would automatically ensure that this logic is always up to date:
```
boolean canCopyMethodAttributes(
final int access,
final String name,
final String descriptor,
final String signature,
final String[] exceptions,
final ClassReader source,
final int sourceOffset,
final int sourceLength) {
if (symbolTable.getSource() == source) {
MethodWriter sourceWriter =
new MethodWriter(
symbolTable, access, name, descriptor, signature, exceptions, COMPUTE_NOTHING);
int methodInfoSize = computeMethodInfoSize();
if (methodInfoSize == sourceWriter.computeMethodInfoSize()) {
ByteVector byteVector = new ByteVector(methodInfoSize * 2);
putMethodInfo(byteVector);
sourceWriter.putMethodInfo(byteVector);
for (int i = 6; i < methodInfoSize; ++i) {
if (byteVector.data[i] != byteVector.data[i + methodInfoSize]) {
return false;
}
}
this.sourceOffset = sourceOffset;
this.sourceLength = sourceLength;
return true;
}
}
return false;
}
```
However, the benchmarks showed this is about 10% slower than the current (buggy) implementation for an optimized transform with the 'copyPool' option. I thus kept the current implementation method (with the bugs fixed), and added a test to make sure this method is updated (if needed) when new attributes are defined.
Closes #317822
Closes #317824Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/161Add a test to make sure ClassWriter.toByteArray() is updated when new ClassWr...2018-04-20T18:04:46ZEric BrunetonAdd a test to make sure ClassWriter.toByteArray() is updated when new ClassWriter fields are added.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/160Resolve "Regression in 6.1: "new Frame" instead of "newFrame" in Analyzer"2018-05-02T18:00:46ZEric BrunetonResolve "Regression in 6.1: "new Frame" instead of "newFrame" in Analyzer"Closes #317821Closes #317821Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/159Fix the checks in CheckMethodAdapter.checkIdentifier for V1_5 or more classes2018-04-15T13:05:07ZEric BrunetonFix the checks in CheckMethodAdapter.checkIdentifier for V1_5 or more classesFix the checks in CheckMethodAdapter.checkIdentifier for V1_5 or more classes, and update all the callers. The requirements were changed in the specification of Java 5 (see section 4.3.2 of https://jcp.org/aboutJava/communityprocess/main...Fix the checks in CheckMethodAdapter.checkIdentifier for V1_5 or more classes, and update all the callers. The requirements were changed in the specification of Java 5 (see section 4.3.2 of https://jcp.org/aboutJava/communityprocess/maintenance/jsr924/index.html).
Closes #317817Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/158Fix the signature checks for JDK9, where rt.jar is not available.2018-04-15T13:00:34ZEric BrunetonFix the signature checks for JDK9, where rt.jar is not available.For reference, the ~450kB jdk8-api.jar was generated from the JDK8 ~64MB rt.jar with the following code, which removes all non public or protected members, skips packages which are not needed and will likely be never needed by ASM, and r...For reference, the ~450kB jdk8-api.jar was generated from the JDK8 ~64MB rt.jar with the following code, which removes all non public or protected members, skips packages which are not needed and will likely be never needed by ASM, and removes all the code from the remaining methods:
```
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.TypePath;
public class JdkApiBuilder {
public static void main(String[] args) throws IOException {
File rtJarFile = new File(args[0]);
ZipFile rtJarZipFile = new ZipFile(rtJarFile);
ZipOutputStream jdkApiJar = new ZipOutputStream(new FileOutputStream(args[1]));
Enumeration<? extends ZipEntry> zipEntries = rtJarZipFile.entries();
while (zipEntries.hasMoreElements()) {
ZipEntry zipEntry = zipEntries.nextElement();
if (zipEntry.isDirectory()) {
jdkApiJar.putNextEntry(zipEntry);
continue;
}
String name = zipEntry.getName();
if (name.startsWith("java/")
&& name.endsWith(".class")
&& !(name.startsWith("java/applet")
|| name.startsWith("java/awt")
|| name.startsWith("java/beans")
|| name.startsWith("java/lang/management")
|| name.startsWith("java/math")
|| name.startsWith("java/net")
|| name.startsWith("java/rmi")
|| name.startsWith("java/security")
|| name.startsWith("java/sql")
|| name.startsWith("java/text")
|| name.startsWith("java/time"))) {
ClassReader classReader = new ClassReader(rtJarZipFile.getInputStream(zipEntry));
if ((classReader.getAccess() & Opcodes.ACC_PUBLIC) == 0) {
continue;
}
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
ClassVisitor classVisitor =
new ClassVisitor(Opcodes.ASM6, classWriter) {
private boolean skipAnnotation(String descriptor) {
return !descriptor.startsWith("java/");
}
@Override
public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitAnnotation(descriptor, visible);
}
@Override
public AnnotationVisitor visitTypeAnnotation(
int typeRef, TypePath typePath, String descriptor, boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitTypeAnnotation(typeRef, typePath, descriptor, visible);
}
@Override
public void visitAttribute(Attribute attribute) {
// Remove non standard attributes.
}
@Override
public FieldVisitor visitField(
int access, String name, String descriptor, String signature, Object value) {
return new FieldVisitor(
Opcodes.ASM6, super.visitField(access, name, descriptor, signature, value)) {
@Override
public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitAnnotation(descriptor, visible);
}
@Override
public AnnotationVisitor visitTypeAnnotation(
int typeRef, TypePath typePath, String descriptor, boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitTypeAnnotation(typeRef, typePath, descriptor, visible);
}
};
}
@Override
public MethodVisitor visitMethod(
final int access,
final String name,
final String descriptor,
final String signature,
final String[] exceptions) {
if ((access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) == 0) {
return null;
}
return new MethodVisitor(
Opcodes.ASM6,
super.visitMethod(access, name, descriptor, signature, exceptions)) {
@Override
public AnnotationVisitor visitAnnotationDefault() {
if (skipAnnotation(descriptor)) return null;
return super.visitAnnotationDefault();
}
@Override
public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitAnnotation(descriptor, visible);
}
@Override
public AnnotationVisitor visitTypeAnnotation(
int typeRef, TypePath typePath, String descriptor, boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitTypeAnnotation(typeRef, typePath, descriptor, visible);
}
@Override
public AnnotationVisitor visitParameterAnnotation(
int parameter, String descriptor, boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitParameterAnnotation(parameter, descriptor, visible);
}
@Override
public void visitAttribute(Attribute attribute) {
// Remove non standard attributes.
}
@Override
public AnnotationVisitor visitInsnAnnotation(
int typeRef, TypePath typePath, String descriptor, boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitInsnAnnotation(typeRef, typePath, descriptor, visible);
}
@Override
public AnnotationVisitor visitTryCatchAnnotation(
int typeRef, TypePath typePath, String descriptor, boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitTryCatchAnnotation(typeRef, typePath, descriptor, visible);
}
@Override
public AnnotationVisitor visitLocalVariableAnnotation(
int typeRef,
TypePath typePath,
Label[] start,
Label[] end,
int[] index,
String descriptor,
boolean visible) {
if (skipAnnotation(descriptor)) return null;
return super.visitLocalVariableAnnotation(
typeRef, typePath, start, end, index, descriptor, visible);
}
@Override
public void visitEnd() {
if ((access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) == 0) {
visitCode();
Type returnType = Type.getReturnType(descriptor);
switch (returnType.getSort()) {
case Type.VOID:
visitInsn(Opcodes.RETURN);
break;
case Type.BOOLEAN:
case Type.CHAR:
case Type.BYTE:
case Type.SHORT:
case Type.INT:
visitInsn(Opcodes.ICONST_0);
visitInsn(Opcodes.IRETURN);
break;
case Type.FLOAT:
visitInsn(Opcodes.FCONST_0);
visitInsn(Opcodes.FRETURN);
break;
case Type.LONG:
visitInsn(Opcodes.LCONST_0);
visitInsn(Opcodes.LRETURN);
break;
case Type.DOUBLE:
visitInsn(Opcodes.DCONST_0);
visitInsn(Opcodes.DRETURN);
break;
case Type.ARRAY:
case Type.OBJECT:
visitInsn(Opcodes.ACONST_NULL);
visitInsn(Opcodes.ARETURN);
break;
default:
throw new AssertionError();
}
visitMaxs(0, 0);
}
super.visitEnd();
}
};
}
};
classReader.accept(classVisitor, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG);
byte[] classFile = classWriter.toByteArray();
jdkApiJar.putNextEntry(new ZipEntry(name));
jdkApiJar.write(classFile, 0, classFile.length);
jdkApiJar.closeEntry();
}
}
jdkApiJar.close();
rtJarZipFile.close();
}
}
```Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/157Improve the code quality of JSRInlinerAdapter.2018-04-08T12:15:51ZEric BrunetonImprove the code quality of JSRInlinerAdapter.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/156Improve the code quality of LocalVariablesSorter.2018-04-08T10:23:18ZEric BrunetonImprove the code quality of LocalVariablesSorter.Remi ForaxRemi Forax