asm merge requestshttps://gitlab.ow2.org/asm/asm/-/merge_requests2021-06-06T07:07:27Zhttps://gitlab.ow2.org/asm/asm/-/merge_requests/320Resolve "CheckClassAdapter visit method does not allow a private or protected...2021-06-06T07:07:27ZEric BrunetonResolve "CheckClassAdapter visit method does not allow a private or protected inner class"Closes #317943.Closes #317943.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/325Use Objects.checkIndex for boundary checking2021-06-22T09:19:44ZYi YangUse Objects.checkIndex for boundary checkingUse Objects.checkIndex for boundary checkingUse Objects.checkIndex for boundary checkinghttps://gitlab.ow2.org/asm/asm/-/merge_requests/313Draft: Add map method for method local variables2021-09-19T10:16:09ZJamie MansfieldDraft: Add map method for method local variablesI'm going to leave this as a draft for a brief time - I want to discuss the change with a few projects that I know remap local variables, and try to make this as workable for them as possible.I'm going to leave this as a draft for a brief time - I want to discuss the change with a few projects that I know remap local variables, and try to make this as workable for them as possible.https://gitlab.ow2.org/asm/asm/-/merge_requests/331Add assertions to InsnList for easier debugging2022-03-14T10:28:28ZAlexeyAdd assertions to InsnList for easier debuggingThis change adds some assertions to InsnList to to make it easier for developers to find bugs in their libraries and applications, for example, by running unit tests with `-ea` flag.This change adds some assertions to InsnList to to make it easier for developers to find bugs in their libraries and applications, for example, by running unit tests with `-ea` flag.https://gitlab.ow2.org/asm/asm/-/merge_requests/337Add getter for `ByteVector.length`2022-03-27T16:14:51ZExE BossAdd getter for `ByteVector.length`This adds the `ByteVector.size()` getter to get the current number of bytes present in the `ByteVector`. The name was chosen to match [`Collection.size()`](https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/util/Collection...This adds the `ByteVector.size()` getter to get the current number of bytes present in the `ByteVector`. The name was chosen to match [`Collection.size()`](https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/util/Collection.html#size()).
When implementing custom `Attribute` subclasses, there were times when I needed to get the size of the `ByteVector`.
---
This was originally merge request [!336](https://gitlab.ow2.org/asm/asm/-/merge_requests/336).https://gitlab.ow2.org/asm/asm/-/merge_requests/344Add an analyzeFromFrames method in Analyzer. This will be used in...2022-04-09T15:39:24ZEric BrunetonAdd an analyzeFromFrames method in Analyzer. This will be used in...Add an analyzeFromFrames method in Analyzer. This will be used in CheckClassAdapter to check frames if they are required and not computed with COMPUTE_FRAMES.Add an analyzeFromFrames method in Analyzer. This will be used in CheckClassAdapter to check frames if they are required and not computed with COMPUTE_FRAMES.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/353Allow for Attributes to be read from/written to via different targets than a ...2022-08-03T06:24:05ZraphwAllow for Attributes to be read from/written to via different targets than a ClassReader/ClassWriter.For interoperability between ASM and other byte code processors (namely the Classfile API in the OpenJDK), it would become necessary to read and write Attributes from and to different targets then a ClassReader or ClassWriter. Currently,...For interoperability between ASM and other byte code processors (namely the Classfile API in the OpenJDK), it would become necessary to read and write Attributes from and to different targets then a ClassReader or ClassWriter. Currently, attributes are resolved against a ClassReader or ClassWriter within a protected method what makes it impossible to resolve the byte representation of an attribute from outside ASM. With this binary compatible change, it would become possible to redirect the reading or writing of attributes to any implementation of a ConstantPool(Sink/Source) which can be then be implemented to resolve constant pool indices against a JDK Classfile constant pool instead of a ClassWriter.
I am using this POC for my POC of integrating ASM with the new API. So far it really seems promising to plug ASM into the new API, but Attributes would require an API adjustment. (This is work in progress, but I would appreciate some early feedback, or an alternative suggestion of how to solve this.)
OpenJDK-ASM POC: https://github.com/raphw/asm-jdk-bridge/tree/writer-pochttps://gitlab.ow2.org/asm/asm/-/merge_requests/362Add CLASS_EXTENDS to visitTypeAnnotation.2022-09-11T07:23:28ZAo LiAdd CLASS_EXTENDS to visitTypeAnnotation.It is possible to have CLASS_EXTENDS annotations in methods (for example https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/ClosingFuture.java#L445). I also attached the compiled class file. [com.goog...It is possible to have CLASS_EXTENDS annotations in methods (for example https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/ClosingFuture.java#L445). I also attached the compiled class file. [com.google.common.util.concurrent.ClosingFuture.class](/uploads/c6a0b7abf9f906fe4e0553093089a765/com.google.common.util.concurrent.ClosingFuture.class)Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/46Don't insert frames when expanding ASM pseudo instructions if EXPAND_FRAMES i...2017-10-19T18:43:41ZEric BrunetonDon't insert frames when expanding ASM pseudo instructions if EXPAND_FRAMES is not set.ASM pseudo instructions are used when jump instructions need to be resized in large methods. To convert them to normal instructions, a new ClassReader->ClassWriter roundtrip is performed, with the EXPAND_ASM_INSNS flag and with the EXPAN...ASM pseudo instructions are used when jump instructions need to be resized in large methods. To convert them to normal instructions, a new ClassReader->ClassWriter roundtrip is performed, with the EXPAND_ASM_INSNS flag and with the EXPAND_FRAMES flag if the class already had frames (see ClassWriter#toByteArray). If EXPAND_FRAMES is false this means the class had initially no frames, despite the fact that it has jump instructions (otherwise there could not be any ASM pseudo insns to replace). Therefore, in this case, we should not attempt to insert frames in ClassReader.
Closes #317800Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/44Remove the workaround introduced for synthetic parameters.2017-11-07T19:34:31ZEric BrunetonRemove the workaround introduced for synthetic parameters.A workaround was added in https://gitlab.ow2.org/asm/asm/commit/4accca37fbf28623afeb46148cdaeec2ad97a6be for issue #307392. The root cause of the bug was that, via a ClassReader->ClassWriter transform, the number of parameter annotations...A workaround was added in https://gitlab.ow2.org/asm/asm/commit/4accca37fbf28623afeb46148cdaeec2ad97a6be for issue #307392. The root cause of the bug was that, via a ClassReader->ClassWriter transform, the number of parameter annotations was not preserved (the number read in ClassReader was ignored, and it was recomputed from the descriptor in MethodWriter).
The workaround added at this time was fixing that, and it was also attempting to report parameter indices corresponding to the source parameters, assuming that the implicit parameters were at added at the begining. However, synthetic parameters can also be added at the end (see issue #317788), so the second part of the above workaround does not work.
This change removes this workaround, and replaces it with a method to preserve the num_parameters value read in ClassReader (via a sentinel annotation). In other words, this change still fixes the root cause of #307392, but no longer attempts to map bytecode parameter indices to source level parameter indices. We believe there is no universal method for doing that, but users can implement their own method, if desired, on top of the ASM API. Indeed, the JVMS spec states that (https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.18):
> The i'th entry in the parameter_annotations table may, but is not required to, correspond to the i'th parameter descriptor in the method descriptor (§4.3.3).
>
> For example, a compiler may choose to create entries in the table corresponding only to those parameter descriptors which represent explicitly declared parameters in source code. In the Java programming language, a constructor of an inner class is specified to have an implicitly declared parameter before its explicitly declared parameters (JLS §8.8.1), so the corresponding <init> method in a class file has a parameter descriptor representing the implicitly declared parameter before any parameter descriptors representing explicitly declared parameters. If the first explicitly declared parameter is annotated in source code, then a compiler may create parameter_annotations[0] to store annotations corresponding to the second parameter descriptor.
Closes #317788Remi ForaxRemi Forax