Summary
-------
Change `java.lang.classfile.Attribute::attributeName` method return type from `String` to `java.lang.classfile.constantpool.Utf8Entry`.
Problem
-------
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.
Solution
--------
Change `java.lang.classfile.Attribute::attributeName` method return type from `String` to `java.lang.classfile.constantpool.Utf8Entry`.
Specification
-------------
```
diff --git a/src/java.base/share/classes/java/lang/classfile/Attribute.java b/src/java.base/share/classes/java/lang/classfile/Attribute.java
index e2f0072d3967f..2d559552684a1 100644
--- a/src/java.base/share/classes/java/lang/classfile/Attribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/Attribute.java
@@ -25,6 +25,7 @@
package java.lang.classfile;
import java.lang.classfile.attribute.*;
+import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
@@ -65,7 +66,7 @@ public sealed interface Attribute<A extends Attribute<A>>
/**
* {@return the name of the attribute}
*/
- String attributeName();
+ Utf8Entry attributeName();
/**
* {@return the {@link AttributeMapper} associated with this attribute}
diff --git a/src/java.base/share/classes/java/lang/classfile/CustomAttribute.java b/src/java.base/share/classes/java/lang/classfile/CustomAttribute.java
index 9fe492dc22c4c..6c3a0de2b7af3 100644
--- a/src/java.base/share/classes/java/lang/classfile/CustomAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/CustomAttribute.java
@@ -24,6 +24,8 @@
*/
package java.lang.classfile;
+import java.lang.classfile.constantpool.Utf8Entry;
+import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.javac.PreviewFeature;
/**
@@ -55,8 +57,8 @@ public final AttributeMapper<T> attributeMapper() {
}
@Override
- public final String attributeName() {
- return mapper.name();
+ public Utf8Entry attributeName() {
+ return TemporaryConstantPool.INSTANCE.utf8Entry(mapper.name());
}
@Override
```