RFR: 8343881: java.lang.classfile.Attribute attributeName() method should return Utf8Entry

Chen Liang liach at openjdk.org
Thu Nov 14 15:58:06 UTC 2024


On Thu, 14 Nov 2024 14:19:58 GMT, Adam Sotona <asotona at openjdk.org> wrote:

> Class-File API usually expose names in a form of `java.lang.classfile.constantpool.Utf8Entry`. Unfortunately `java.lang.classfile.Attribute::attributeName` method was omitted during the API review and it returns inflated `String` value of the name.
> 
> This patch changes return type of `java.lang.classfile.Attribute::attributeName` from `String` to `java.lang.classfile.constantpool.Utf8Entry`.
> 
> Please review.
> 
> Thanks,
> Adam

Can you change `AbstractAttributeMapper` to write the `attributeName` utf8 entry instead of looking up on write?

This changeset looks good to me.

src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java line 445:

> 443:         @Override
> 444:         public Utf8Entry attributeName() {
> 445:             return NAME;

Maybe `buf.constantPool().utf8Entry(NAME_LINE_NUMBER_TABLE)`?

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

PR Review: https://git.openjdk.org/jdk/pull/22107#pullrequestreview-2436361636
Marked as reviewed by liach (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/22107#pullrequestreview-2436478500
PR Review Comment: https://git.openjdk.org/jdk/pull/22107#discussion_r1842434757


More information about the core-libs-dev mailing list