8345319: Fix the tag type in PoolEntry and AnnotationValue

Reviewed-by: asotona
This commit is contained in:
Chen Liang 2024-12-03 16:59:57 +00:00
parent e9f6ba0526
commit 76e874c08e
7 changed files with 46 additions and 43 deletions

View file

@ -456,9 +456,11 @@ public sealed interface AnnotationValue {
*
* @apiNote
* {@code TAG_}-prefixed constants in this class, such as {@link #TAG_INT},
* describe the possible return values of this method.
* describe the possible return values of this method. The return type is
* {@code int} for consistency with union indicator items in other union
* structures in the {@code class} file format.
*/
char tag();
int tag();
/**
* {@return an enum value for an element-value pair}

View file

@ -98,7 +98,7 @@ public sealed interface PoolEntry
* {@code TAG_}-prefixed constants in this class, such as {@link #TAG_UTF8},
* describe the possible return values of this method.
*/
byte tag();
int tag();
/**
* {@return the index within the constant pool corresponding to this entry}

View file

@ -104,7 +104,7 @@ public abstract sealed class AbstractPoolEntry {
return hash;
}
public abstract byte tag();
public abstract int tag();
public int width() {
return 1;
@ -181,7 +181,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_UTF8;
}
@ -522,7 +522,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_CLASS;
}
@ -582,7 +582,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_PACKAGE;
}
@ -613,7 +613,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_MODULE;
}
@ -645,7 +645,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_NAME_AND_TYPE;
}
@ -719,7 +719,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_FIELDREF;
}
@ -737,7 +737,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_METHODREF;
}
@ -755,7 +755,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_INTERFACE_METHODREF;
}
@ -849,7 +849,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_INVOKE_DYNAMIC;
}
@ -874,7 +874,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_DYNAMIC;
}
@ -905,7 +905,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_METHOD_HANDLE;
}
@ -964,7 +964,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_METHOD_TYPE;
}
@ -1002,7 +1002,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_STRING;
}
@ -1054,7 +1054,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_INTEGER;
}
@ -1100,7 +1100,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_FLOAT;
}
@ -1145,7 +1145,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_LONG;
}
@ -1195,7 +1195,7 @@ public abstract sealed class AbstractPoolEntry {
}
@Override
public byte tag() {
public int tag() {
return TAG_DOUBLE;
}

View file

@ -72,7 +72,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfStringImpl(Utf8Entry constant)
implements AnnotationValue.OfString {
@Override
public char tag() {
public int tag() {
return TAG_STRING;
}
@ -85,7 +85,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfDoubleImpl(DoubleEntry constant)
implements AnnotationValue.OfDouble {
@Override
public char tag() {
public int tag() {
return TAG_DOUBLE;
}
@ -98,7 +98,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfFloatImpl(FloatEntry constant)
implements AnnotationValue.OfFloat {
@Override
public char tag() {
public int tag() {
return TAG_FLOAT;
}
@ -111,7 +111,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfLongImpl(LongEntry constant)
implements AnnotationValue.OfLong {
@Override
public char tag() {
public int tag() {
return TAG_LONG;
}
@ -124,7 +124,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfIntImpl(IntegerEntry constant)
implements AnnotationValue.OfInt {
@Override
public char tag() {
public int tag() {
return TAG_INT;
}
@ -137,7 +137,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfShortImpl(IntegerEntry constant)
implements AnnotationValue.OfShort {
@Override
public char tag() {
public int tag() {
return TAG_SHORT;
}
@ -150,7 +150,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfCharImpl(IntegerEntry constant)
implements AnnotationValue.OfChar {
@Override
public char tag() {
public int tag() {
return TAG_CHAR;
}
@ -163,7 +163,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfByteImpl(IntegerEntry constant)
implements AnnotationValue.OfByte {
@Override
public char tag() {
public int tag() {
return TAG_BYTE;
}
@ -176,7 +176,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfBooleanImpl(IntegerEntry constant)
implements AnnotationValue.OfBoolean {
@Override
public char tag() {
public int tag() {
return TAG_BOOLEAN;
}
@ -193,7 +193,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
}
@Override
public char tag() {
public int tag() {
return TAG_ARRAY;
}
}
@ -201,7 +201,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfEnumImpl(Utf8Entry className, Utf8Entry constantName)
implements AnnotationValue.OfEnum {
@Override
public char tag() {
public int tag() {
return TAG_ENUM;
}
}
@ -209,7 +209,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfAnnotationImpl(Annotation annotation)
implements AnnotationValue.OfAnnotation {
@Override
public char tag() {
public int tag() {
return TAG_ANNOTATION;
}
}
@ -217,7 +217,7 @@ public record AnnotationImpl(Utf8Entry className, List<AnnotationElement> elemen
public record OfClassImpl(Utf8Entry className)
implements AnnotationValue.OfClass {
@Override
public char tag() {
public int tag() {
return TAG_CLASS;
}
}

View file

@ -354,7 +354,7 @@ public final class AnnotationReader {
public static void writeAnnotationValue(BufWriterImpl buf, AnnotationValue value) {
var tag = value.tag();
buf.writeU1(tag);
switch (value.tag()) {
switch (tag) {
case TAG_BOOLEAN, TAG_BYTE, TAG_CHAR, TAG_DOUBLE, TAG_FLOAT, TAG_INT, TAG_LONG, TAG_SHORT, TAG_STRING ->
buf.writeIndex(((AnnotationValue.OfConstant) value).constant());
case TAG_CLASS -> buf.writeIndex(((AnnotationValue.OfClass) value).className());