Skip to content

Commit 5d0640a

Browse files
committed
Use MergedAnnotations for @AliasFor support
Update `ImportsContextCustomizer` to use `MergedAnnotations` so that `@AliasFor` can be supported. See gh-34917
1 parent 9baf23c commit 5d0640a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,6 +43,9 @@
4343
import org.springframework.context.support.AbstractApplicationContext;
4444
import org.springframework.core.Ordered;
4545
import org.springframework.core.annotation.AnnotationUtils;
46+
import org.springframework.core.annotation.MergedAnnotation;
47+
import org.springframework.core.annotation.MergedAnnotations;
48+
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
4649
import org.springframework.core.annotation.Order;
4750
import org.springframework.core.style.ToStringCreator;
4851
import org.springframework.core.type.AnnotationMetadata;
@@ -251,7 +254,9 @@ private void collectClassAnnotations(Class<?> classType, Set<Annotation> annotat
251254

252255
private void collectElementAnnotations(AnnotatedElement element, Set<Annotation> annotations,
253256
Set<Class<?>> seen) {
254-
for (Annotation annotation : element.getDeclaredAnnotations()) {
257+
for (MergedAnnotation<Annotation> mergedAnnotation : MergedAnnotations.from(element,
258+
SearchStrategy.DIRECT)) {
259+
Annotation annotation = mergedAnnotation.synthesize();
255260
if (!isIgnoredAnnotation(annotation)) {
256261
annotations.add(annotation);
257262
collectClassAnnotations(annotation.annotationType(), annotations, seen);

0 commit comments

Comments
 (0)