Skip to content

ClassFileAnnotationMetadata.fromTypeDescriptor(…) fails on Java 24 #34882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mp911de opened this issue May 12, 2025 · 3 comments
Closed

ClassFileAnnotationMetadata.fromTypeDescriptor(…) fails on Java 24 #34882

mp911de opened this issue May 12, 2025 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@mp911de
Copy link
Member

mp911de commented May 12, 2025

Reproducer:

@NamedStoredProcedureQueries({ //
		@NamedStoredProcedureQuery(name = "Dummy.procedureWith1InputAnd1OutputParameterWithResultSetWithUpdate",
				procedureName = "procedure_in1_out0_return_rs_with_update",
				parameters = { @StoredProcedureParameter(type = void.class) }) //
})
public class Dummy {

}

new CachingMetadataReaderFactory().getMetadataReader("com.example.demo.Dummy").getAnnotationMetadata();

(Caused by type.void)

Caused by: java.lang.StringIndexOutOfBoundsException: Range [1, 0) out of bounds for length 1
11:01:22  	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
11:01:22  	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
11:01:22  	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
11:01:22  	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
11:01:22  	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
11:01:22  	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
11:01:22  	at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
11:01:22  	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4950)
11:01:22  	at java.base/java.lang.String.substring(String.java:2912)
11:01:22  	at org.springframework.core.type.classreading.ClassFileAnnotationMetadata.fromTypeDescriptor(ClassFileAnnotationMetadata.java:100)
11:01:22  	at org.springframework.core.type.classreading.ClassFileAnnotationMetadata.readAnnotationValue(ClassFileAnnotationMetadata.java:88)
11:01:22  	at org.springframework.core.type.classreading.ClassFileAnnotationMetadata.createMergedAnnotation(ClassFileAnnotationMetadata.java:65)
11:01:22  	at org.springframework.core.type.classreading.ClassFileAnnotationMetadata.readAnnotationValue(ClassFileAnnotationMetadata.java:85)
11:01:22  	at org.springframework.core.type.classreading.ClassFileAnnotationMetadata.lambda$parseArrayValue$0(ClassFileAnnotationMetadata.java:122)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 12, 2025
@bclozel bclozel self-assigned this May 12, 2025
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label May 12, 2025
@bclozel bclozel added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on in: core Issues in core modules (aop, beans, core, context, expression) labels May 12, 2025
@bclozel bclozel added this to the 7.0.0-M5 milestone May 12, 2025
@bclozel bclozel added the in: core Issues in core modules (aop, beans, core, context, expression) label May 12, 2025
@bclozel
Copy link
Member

bclozel commented May 12, 2025

Fixed with 233eb7f

@bclozel bclozel closed this as completed May 12, 2025
@bclozel
Copy link
Member

bclozel commented May 12, 2025

Thanks for the report @mp911de !

@sbrannen
Copy link
Member

Reopening since the current fix only works if the primitive type name is the same as the wrapper type name, ignoring case.

For example, the following test fails with:

java.lang.IllegalArgumentException: Could not find class [java.lang.Int]
	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:350)
	at org.springframework.core.annotation.TypeMappedAnnotation.adapt(TypeMappedAnnotation.java:439)
	at org.springframework.core.annotation.TypeMappedAnnotation.getValue(TypeMappedAnnotation.java:384)
	at org.springframework.core.annotation.TypeMappedAnnotation.asMap(TypeMappedAnnotation.java:273)
	at org.springframework.core.annotation.TypeMappedAnnotation.asMap(TypeMappedAnnotation.java:262)
	at org.springframework.core.annotation.MergedAnnotationCollectors.lambda$toMultiValueMap$1(MergedAnnotationCollectors.java:138)
@Test
void getAnnotationAttributeIntType() {
	MultiValueMap<String, Object> attributes =
			get(WithIntType.class).getAllAnnotationAttributes(ComplexAttributes.class.getName());
	assertThat(attributes).containsOnlyKeys("names", "count", "type", "subAnnotation");
	assertThat(attributes.get("type")).containsAnyOf(Integer.class, int.class);
}
@ComplexAttributes(names = "int", count = TestEnum.ONE, type = int.class,
		subAnnotation = @SubAnnotation(name="spring"))
public static class WithIntType {
}

@sbrannen sbrannen reopened this May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants