JDK-8343881 : java.lang.classfile.Attribute attributeName() method should return Utf8Entry
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang.classfile
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-11-08
  • Updated: 2024-11-15
  • Resolved: 2024-11-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 masterFixed
Related Reports
CSR :  
Description
ADDITIONAL SYSTEM INFORMATION :
does not apply

A DESCRIPTION OF THE PROBLEM :
The attributName() method currently returns a String with the attribute name.  I believe it should return the actual Utf8Entry in the class file.  The stringValue() method would then return the attribute name.  This is the way almost all the subinterfaces of Attribute work.  Without the Utf8Entry information it is very difficult to write a class file dumper that shows the detailed contents of the class file as well as the symbolic information.



Comments
Changeset: ba393219 Branch: master Author: Adam Sotona <asotona@openjdk.org> Date: 2024-11-15 11:40:15 +0000 URL: https://git.openjdk.org/jdk/commit/ba39321902400e103cdce0b326d0005123b1d87e
15-11-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/22107 Date: 2024-11-14 14:19:58 +0000
14-11-2024

Changing from Bug to Enhancement as attribute names in String form do not prevent detailed class file dump, constant pool is available. As a workaround ConstantPoolBuilder is able to find the relevant Utf8Entry during transform.
14-11-2024

Yes, it similar situations the API usually return Utf8Entry. However all attributes have statically defined names and their actual Utf8Entries are not passed to nor persisted in the Attribute instances. Changes necessary to expose attribute name as the actual Utf8Entry would involve also AttributeMapper API and CustomAttribute contract. Negative performance impact is also expected. This RFE needs to be discussed before further steps.
14-11-2024

Moved to JDK for more discussions.
09-11-2024