asm merge requestshttps://gitlab.ow2.org/asm/asm/-/merge_requests2017-11-14T18:57:50Zhttps://gitlab.ow2.org/asm/asm/-/merge_requests/68Improve the code quality of SignatureReader and SignatureWriter.2017-11-14T18:57:50ZEric BrunetonImprove the code quality of SignatureReader and SignatureWriter.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/67Improve the code quality of ModuleWriter.2017-11-19T08:44:29ZEric BrunetonImprove the code quality of ModuleWriter.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/66Improve the code quality of Item and of related code in ClassWriter and Class...2017-11-25T07:07:40ZEric BrunetonImprove the code quality of Item and of related code in ClassWriter and ClassReader.- Item was a mutable class with many set* methods, used to set predefined Item key instances in ClassWriter, to perform lookups (while avoiding the creation of new instances for this). These preallocated keys were error prone, due to the...- Item was a mutable class with many set* methods, used to set predefined Item key instances in ClassWriter, to perform lookups (while avoiding the creation of new instances for this). These preallocated keys were error prone, due to the nested calls (a nested call could inadvertently modify the key used by a caller).
- The Javadoc was largely obsolete, refering mostly to the constant pool, while Item was also used for bootstrap methods and for the ASM specific type table.
- The number of elements in ClassWriter#items was poorly tracked, for instance bootstrap methods were not taken into account in ClassWriter#put.
- The threshold to limit hash collisions was not always respected (for instance in copyPool, items was created with a size equal to the constant pool count, without margin).
- Lookups in ClassWriter#get were not optimal: a check on hashcode could be used before calling the expensive isEqualTo method.
Now Item is replaced with Symbol, which is immutable (except for the lazily computed info field). Also the hashCode and next fields are hidden in a private subclass (they are only used inside SymbolTable).
The preallocated Item key, key2, ... fields are removed, while keeping the zero allocation property for lookups.
The number of elements in entries is now explicitely tracked with entryCount, and the threshold is correctly used.
Lookups are now optimized to do a quick hashcode comparison before slow equality tests.
All Symbol management is now done is a separate SymbolTable class, allowing a cleaner implementation for the copyPool option (more private fields, less exposure of internal details to other classes).
According to performance tests using benchmarks/read-write, this new code is slightly faster than before (e.g. ~1.05 speedup for R+W with or without copyPool).
The jar size is now 99581 bytes vs 95209 for ASM 6.0.
This is a large refactor, please review carefully.
PS: I spent several days on this, and considered several designs before choosing this one. For instance, I also considered splitting SymbolTable in 3 (e.g. ConstantPoolWriter, BootstrapMethodsWriter and TypeTable, all delegating to a shared (custom) HashSet), and/or splitting Symbol using one class per type of symbol, to get something even more clean from an Object Oriented design point of view. But I rejected this as "going too far" from the current design.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/65Fix the Javadoc errors and fail the build on Javadoc errors.2017-10-31T11:30:08ZEric BrunetonFix the Javadoc errors and fail the build on Javadoc errors.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/64Improve the code quality of FieldWriter.2017-10-31T10:37:10ZEric BrunetonImprove the code quality of FieldWriter.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/63Improve the code quality of Handler and Handle.2017-10-22T13:53:12ZEric BrunetonImprove the code quality of Handler and Handle.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/62Improve the code quality of Edge.2017-10-22T13:51:47ZEric BrunetonImprove the code quality of Edge.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/61Improve the code quality of Context.2017-10-22T13:49:53ZEric BrunetonImprove the code quality of Context.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/60Improve the code quality of ByteVector.2017-10-22T13:47:30ZEric BrunetonImprove the code quality of ByteVector.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/59Improve the code quality of Attribute.2017-10-22T13:44:17ZEric BrunetonImprove the code quality of Attribute.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/58Improve the code quality of TypePath and TypeReference.2017-10-22T13:41:01ZEric BrunetonImprove the code quality of TypePath and TypeReference.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/57Improve the code quality of AnnotationWriter.2017-10-22T13:33:12ZEric BrunetonImprove the code quality of AnnotationWriter.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/56Remove the workaround introduced for synthetic parameters.2018-03-11T21:50:38ZEric BrunetonRemove the workaround introduced for synthetic parameters.A workaround was added in 4accca37 for issue #307392. The root cause of the bug was that, via a ClassReader->ClassWriter transform, the length of the parameter_annotations array in the Runtime[In]VisibleParameterAnnotations attribute was...A workaround was added in 4accca37 for issue #307392. The root cause of the bug was that, via a ClassReader->ClassWriter transform, the length of the parameter_annotations array in the Runtime[In]VisibleParameterAnnotations attribute 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 new visitAnnotableParameterCount method to preserve the size of the above array in a ClassReader->ClassWriter chain. In other words, this change still fixes the root cause of #307392 (closed), 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.
Note that the new visit method need not be called. By default (for instance for classes generated from scratch, without a ClassReader), the number of annotable parameters is the number of parameters in the method descriptor. This was also the case with the current code (i.e. when no ASM specific Ljava/lang/Synthetic; annotation was used to mark synthetic parameters). In theory, we should define a new API version, e.g. ASM_6_1, and implement the full backward compatibility mechanism for this new visit method, but I'm not sure it is worth doing so. What do you think?
Closes #317788Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/55Fix the sigtest task.2017-10-22T13:26:03ZEric BrunetonFix the sigtest task.The signature test was not working without the rt.jar on the classpath (no error was reported for incompatible API changes). Adding it solves this issue, and also removes the warnings about the @Deprecated annotations. I also had to manu...The signature test was not working without the rt.jar on the classpath (no error was reported for incompatible API changes). Adding it solves this issue, and also removes the warnings about the @Deprecated annotations. I also had to manually fix the asm-xml signature files (for some unknown reason the inner ASMContentHandler$Rule class was recorded as public, whereas it has always been protected).Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/54Deprecate the XML API.2017-10-31T10:37:50ZEric BrunetonDeprecate the XML API.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/53Delete the examples.2017-10-31T10:40:35ZEric BrunetonDelete the examples.These examples were introduced long before the user guide, which now provides more and better documented examples.These examples were introduced long before the user guide, which now provides more and better documented examples.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/52Don't insert frames when expanding ASM pseudo instructions if EXPAND_FRAMES i...2017-10-31T10:42:21ZEric 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/51Remove the duplicated signature files.2017-10-22T13:10:39ZEric BrunetonRemove the duplicated signature files.Some files differ from the content for the previous version only by the version number line, everything else being identical. They can be removed since they only give redundant tests and increase the build time for nothing.Some files differ from the content for the previous version only by the version number line, everything else being identical. They can be removed since they only give redundant tests and increase the build time for nothing.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/50Switch to JUnit 5.2017-11-01T08:34:45ZEric BrunetonSwitch to JUnit 5.Remi ForaxRemi Foraxhttps://gitlab.ow2.org/asm/asm/-/merge_requests/49Add the signature files for ASM 6.0.2017-10-22T13:11:24ZEric BrunetonAdd the signature files for ASM 6.0.Remi ForaxRemi Forax