RFR: 8331291: java.lang.classfile.Attributes class performs a lot of static initializations [v7]

Vicente Romero vromero at openjdk.org
Mon May 6 18:35:57 UTC 2024


On Mon, 6 May 2024 16:07:26 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> Hi,
>> During performance optimization work on Class-File API as JDK lambda generator we found some static initialization killers.
>> One of them is `java.lang.classfile.Attributes` with tens of static fields initialized with individual attribute mappers, and common set of all mappers, and static map from attribute names to the mappers.
>> 
>> I propose to turn all the static fields into lazy-initialized static methods and remove `PREDEFINED_ATTRIBUTES` and `standardAttribute(Utf8Entry name)` static mapping method from the `Attributes` API class.
>>  
>> Please let me know your comments or objections and please review the [PR](https://github.com/openjdk/jdk/pull/19006) and [CSR](https://bugs.openjdk.org/browse/JDK-8331414), so we can make it into 23.
>> 
>> Thank you,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
> 
>   fixed tests

lgtm

src/java.base/share/classes/java/lang/classfile/Attributes.java line 28:

> 26: 
> 27: import java.lang.classfile.attribute.*;
> 28: import jdk.internal.classfile.impl.AbstractAttributeMapper.*;

the second star import is probably unnecessary

-------------

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/19006#pullrequestreview-2041378994
PR Review Comment: https://git.openjdk.org/jdk/pull/19006#discussion_r1591377928


More information about the hotspot-compiler-dev mailing list