Fix StringIndexOutOfBoundsException with Class-File metadata

Closes gh-34882
This commit is contained in:
Brian Clozel
2025-05-13 16:15:00 +02:00
parent 261862076c
commit 0df75ff75e
2 changed files with 6 additions and 7 deletions

View File

@@ -37,7 +37,6 @@ import org.springframework.core.annotation.AnnotationFilter;
import org.springframework.core.annotation.MergedAnnotation;
import org.springframework.core.annotation.MergedAnnotations;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
* Parse {@link RuntimeVisibleAnnotationsAttribute} into {@link MergedAnnotations}
@@ -100,7 +99,7 @@ abstract class ClassFileAnnotationMetadata {
private static String fromTypeDescriptor(String descriptor) {
ClassDesc classDesc = ClassDesc.ofDescriptor(descriptor);
return classDesc.isPrimitive() ? "java.lang." + StringUtils.capitalize(classDesc.displayName()) :
return classDesc.isPrimitive() ? classDesc.displayName() :
classDesc.packageName() + "." + classDesc.displayName();
}

View File

@@ -309,11 +309,11 @@ public abstract class AbstractAnnotationMetadataTests {
}
@Test
void getAnnotationAttributeVoidType() {
void getAnnotationAttributeIntType() {
MultiValueMap<String, Object> attributes =
get(WithVoidType.class).getAllAnnotationAttributes(ComplexAttributes.class.getName());
get(WithIntType.class).getAllAnnotationAttributes(ComplexAttributes.class.getName());
assertThat(attributes).containsOnlyKeys("names", "count", "type", "subAnnotation");
assertThat(attributes.get("type")).containsAnyOf(Void.class, void.class);
assertThat(attributes.get("type")).contains(int.class);
}
@Test
@@ -460,9 +460,9 @@ public abstract class AbstractAnnotationMetadataTests {
public static class WithComplexAttributeTypes {
}
@ComplexAttributes(names = "void", count = TestEnum.ONE, type = void.class,
@ComplexAttributes(names = "void", count = TestEnum.ONE, type = int.class,
subAnnotation = @SubAnnotation(name="spring"))
public static class WithVoidType {
public static class WithIntType {
}