Skip to content

Commit

Permalink
Reversion of AttributeMapper changes
Browse files Browse the repository at this point in the history
  • Loading branch information
asotona committed Nov 14, 2024
1 parent 0e9a8ca commit ae06f4e
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package java.lang.classfile;

import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.javac.PreviewFeature;

/**
Expand Down Expand Up @@ -89,14 +88,13 @@ enum AttributeStability {
/**
* Create an {@link Attribute} instance from a classfile.
*
* @param name Attribute name
* @param enclosing The class, method, field, or code attribute in which
* this attribute appears
* @param cf The {@link ClassReader} describing the classfile to read from
* @param pos The offset into the classfile at which the attribute starts
* @return the new attribute
*/
A readAttribute(Utf8Entry name, AttributedElement enclosing, ClassReader cf, int pos);
A readAttribute(AttributedElement enclosing, ClassReader cf, int pos);

/**
* Write an {@link Attribute} instance to a classfile.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,13 @@
public abstract non-sealed class CustomAttribute<T extends CustomAttribute<T>>
implements Attribute<T>, CodeElement, ClassElement, MethodElement, FieldElement {

private final Utf8Entry name;
private final AttributeMapper<T> mapper;

/**
* Construct a {@linkplain CustomAttribute}.
* @param mapper the attribute mapper
*/
protected CustomAttribute(AttributeMapper<T> mapper) {
this(TemporaryConstantPool.INSTANCE.utf8Entry(mapper.name()), mapper);
}

/**
* Construct a {@linkplain CustomAttribute}.
* @param name the attribute name
* @param mapper the attribute mapper
*/
protected CustomAttribute(Utf8Entry name, AttributeMapper<T> mapper) {
this.name = name;
this.mapper = mapper;
}

Expand All @@ -68,8 +57,8 @@ public final AttributeMapper<T> attributeMapper() {
}

@Override
public final Utf8Entry attributeName() {
return name;
public Utf8Entry attributeName() {
return TemporaryConstantPool.INSTANCE.utf8Entry(mapper.name());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
* Attributes are converted between their classfile form and their corresponding
* object form via an {@link java.lang.classfile.AttributeMapper}. An {@code
* AttributeMapper} provides the
* {@link java.lang.classfile.AttributeMapper#readAttribute(Utf8Entry, AttributedElement,
* {@link java.lang.classfile.AttributeMapper#readAttribute(AttributedElement,
* ClassReader, int)} method for mapping from the classfile format
* to an attribute instance, and the
* {@link java.lang.classfile.AttributeMapper#writeAttribute(java.lang.classfile.BufWriter,
Expand Down
Loading

0 comments on commit ae06f4e

Please sign in to comment.