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

Chen Liang liach at openjdk.org
Thu May 2 14:43:00 UTC 2024


On Thu, 2 May 2024 11:08:16 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 with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8331291-attributes
>  - changed order in allowed modules attributes check
>  - added bug number
>  - added impl comment
>  - removed list of predefined attributes
>    standard attributes mapping hard-coded and moved to BoundAttribute
>    added AttributesTest::testAttributesMapping
>  - move mappers implementations to AbstractAttributeMapper
>  - 8331291: java.lang.classfile.Attributes class performs a lot of static initializations

On a side note, will we update JEP 466 to include this patch?

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

Marked as reviewed by liach (Author).

PR Review: https://git.openjdk.org/jdk/pull/19006#pullrequestreview-2035945054


More information about the compiler-dev mailing list