Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asotona committed Nov 14, 2024
1 parent dbf2766 commit 6fb1138
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions test/jdk/jdk/classfile/helpers/RebuildingTransformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ static byte[] transform(ClassModel clm) {
case RuntimeVisibleTypeAnnotationsAttribute a -> fb.with(RuntimeVisibleTypeAnnotationsAttribute.of(transformTypeAnnotations(a.annotations(), null, null)));
case SignatureAttribute a -> fb.with(SignatureAttribute.of(Signature.parseFrom(a.asTypeSignature().signatureString())));
case SyntheticAttribute a -> fb.with(SyntheticAttribute.of());
case CustomAttribute a -> throw new AssertionError("Unexpected custom attribute: " + a.attributeName());
case UnknownAttribute a -> throw new AssertionError("Unexpected unknown attribute: " + a.attributeName());
case CustomAttribute a -> throw new AssertionError("Unexpected custom attribute: " + a.attributeName().stringValue());
case UnknownAttribute a -> throw new AssertionError("Unexpected unknown attribute: " + a.attributeName().stringValue());
}
}
});
Expand Down Expand Up @@ -91,8 +91,8 @@ static byte[] transform(ClassModel clm) {
case RuntimeVisibleTypeAnnotationsAttribute a -> mb.with(RuntimeVisibleTypeAnnotationsAttribute.of(transformTypeAnnotations(a.annotations(), null, null)));
case SignatureAttribute a -> mb.with(SignatureAttribute.of(MethodSignature.parseFrom(a.asMethodSignature().signatureString())));
case SyntheticAttribute a -> mb.with(SyntheticAttribute.of());
case CustomAttribute a -> throw new AssertionError("Unexpected custom attribute: " + a.attributeName());
case UnknownAttribute a -> throw new AssertionError("Unexpected unknown attribute: " + a.attributeName());
case CustomAttribute a -> throw new AssertionError("Unexpected custom attribute: " + a.attributeName().stringValue());
case UnknownAttribute a -> throw new AssertionError("Unexpected unknown attribute: " + a.attributeName().stringValue());
}
}
});
Expand Down Expand Up @@ -131,7 +131,7 @@ static byte[] transform(ClassModel clm) {
case RuntimeVisibleAnnotationsAttribute rvaa -> rcac.accept(RuntimeVisibleAnnotationsAttribute.of(transformAnnotations(rvaa.annotations())));
case RuntimeVisibleTypeAnnotationsAttribute rvtaa -> rcac.accept(RuntimeVisibleTypeAnnotationsAttribute.of(transformTypeAnnotations(rvtaa.annotations(), null, null)));
case SignatureAttribute sa -> rcac.accept(SignatureAttribute.of(Signature.parseFrom(sa.asTypeSignature().signatureString())));
default -> throw new AssertionError("Unexpected record component attribute: " + rca.attributeName());
default -> throw new AssertionError("Unexpected record component attribute: " + rca.attributeName().stringValue());
}}).toArray(Attribute[]::new))).toArray(RecordComponentInfo[]::new)));
case RuntimeInvisibleAnnotationsAttribute a -> clb.with(RuntimeInvisibleAnnotationsAttribute.of(transformAnnotations(a.annotations())));
case RuntimeInvisibleTypeAnnotationsAttribute a -> clb.with(RuntimeInvisibleTypeAnnotationsAttribute.of(transformTypeAnnotations(a.annotations(), null, null)));
Expand All @@ -142,8 +142,8 @@ static byte[] transform(ClassModel clm) {
case SourceFileAttribute a -> clb.with(SourceFileAttribute.of(a.sourceFile().stringValue()));
case SourceIDAttribute a -> clb.with(SourceIDAttribute.of(a.sourceId().stringValue()));
case SyntheticAttribute a -> clb.with(SyntheticAttribute.of());
case CustomAttribute a -> throw new AssertionError("Unexpected custom attribute: " + a.attributeName());
case UnknownAttribute a -> throw new AssertionError("Unexpected unknown attribute: " + a.attributeName());
case CustomAttribute a -> throw new AssertionError("Unexpected custom attribute: " + a.attributeName().stringValue());
case UnknownAttribute a -> throw new AssertionError("Unexpected unknown attribute: " + a.attributeName().stringValue());
}
}
});
Expand Down Expand Up @@ -595,7 +595,7 @@ else switch (i.constantValue()) {
transformFrameTypeInfos(fr.locals(), cob, labels),
transformFrameTypeInfos(fr.stack(), cob, labels))).toList()));
case CustomAttribute a ->
throw new AssertionError("Unexpected custom attribute: " + a.attributeName());
throw new AssertionError("Unexpected custom attribute: " + a.attributeName().stringValue());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void test(String template, Map<String, String> replacements, boolean has
checkEquals(countNumberOfAttributes(method.attributes()),
1L,
"Number of AnnotationDefault attribute");
checkEquals(attr.attributeName(),
checkEquals(attr.attributeName().stringValue(),
"AnnotationDefault", "attribute_name_index");

ExpectedValues expectedValue = expectedValues.get(methodName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private void testEnclosingMethodAttribute() {
// stop checking, attr is null. test case failed
return;
}
checkEquals(attr.attributeName(),
checkEquals(attr.attributeName().stringValue(),
"EnclosingMethod",
"attribute_name_index of EnclosingMethod attribute in the class : " + className);
checkEquals(((BoundAttribute<?>)attr).payloadLen(), 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private void verifyCoveredLines(Set<Integer> actualCoveredLines, TestCase.Method
private <T extends Attribute<T>> int countAttributes(AttributeMapper<T> attr, AttributedElement attributedElement) {
int i = 0;
for (Attribute<?> attribute : attributedElement.attributes()) {
if (attribute.attributeName().equals(attr.name())) {
if (attribute.attributeName().equalsString(attr.name())) {
i++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private void testAttribute(

SignatureAttribute attribute = sup.get();
if (expectedSignature != null && checkNotNull(attribute, memberName + " must have attribute")) {
checkEquals(attribute.attributeName(),
checkEquals(attribute.attributeName().stringValue(),
"Signature", "Attribute's name : " + memberName);
checkEquals(((BoundAttribute<?>)attribute).payloadLen(), 2, "Attribute's length : " + memberName);
checkEquals(attribute.signature().stringValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void assertAttributePresent(ClassModel classFile, String fileName) throw

SourceFileAttribute attribute = sourceFileAttributes.get(0);

assertEquals(attribute.attributeName(), Attributes.sourceFile().name(), "Incorrect attribute name");
assertEquals(attribute.attributeName().stringValue(), Attributes.sourceFile().name(), "Incorrect attribute name");
assertEquals(attribute.sourceFile().stringValue(), fileName,
"Incorrect source file name");
assertEquals(((BoundAttribute<?>)attribute).payloadLen(), 2, "Incorrect attribute length");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void testDeprecatedAttribute(String name, DeprecatedAttribute attr, Clas
if (checkNotNull(attr, name + " must have deprecated attribute")) {
checkEquals(0, ((BoundAttribute<?>)attr).payloadLen(),
"attribute_length should equal to 0");
checkEquals("Deprecated", attr.attributeName(),
checkEquals("Deprecated", attr.attributeName().stringValue(),
name + " attribute_name_index");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private void test(String classToTest, TestCase test, String...skipClasses) {
if (!checkNotNull(innerClasses, "InnerClasses attribute should not be null")) {
return;
}
checkEquals(innerClasses.attributeName(), "InnerClasses",
checkEquals(innerClasses.attributeName().stringValue(), "InnerClasses",
"innerClasses.attribute_name_index");
// Inner Classes attribute consists of length (2 bytes)
// and 8 bytes for each inner class's entry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ enum CheckFor {
void check(ClassModel classFile) throws Exception {
boolean found = false;
for (Attribute<?> attr: classFile.attributes()) {
if (attr.attributeName().equals("PermittedSubclasses")) {
if (attr.attributeName().equalsString("PermittedSubclasses")) {
PermittedSubclassesAttribute permittedSubclasses = (PermittedSubclassesAttribute)attr;
found = true;
if (permittedSubclasses.permittedSubclasses().isEmpty()) {
Expand All @@ -99,7 +99,7 @@ void check(ClassModel classFile) throws Exception {
NOT_SEALED {
void check(ClassModel classFile) throws Exception {
for (Attribute<?> attr: classFile.attributes()) {
if (attr.attributeName().equals("PermittedSubclasses")) {
if (attr.attributeName().equalsString("PermittedSubclasses")) {
throw new AssertionError(classFile.thisClass().name() + " should not be sealed");
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/langtools/tools/javap/T6716452.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <T extends Attribute<T>> void test(MethodModel mm, AttributeMapper<T> attr, Clas
if (!c.isAssignableFrom(mm.attributes().get(index).getClass())) {
error(mm + ": unexpected attribute found,"
+ " expected " + c.getName()
+ " found " + mm.attributes().get(index).attributeName());
+ " found " + mm.attributes().get(index).attributeName().stringValue());
}
} else {
error(mm + ": expected attribute " + attr.name() + " not found");
Expand Down

0 comments on commit 6fb1138

Please sign in to comment.