Skip to content

Commit

Permalink
Revert "Deprecate "enclosing classes" search strategy for MergedAnnot…
Browse files Browse the repository at this point in the history
…ations"

This reverts commit 5689395.

See gh-28079
  • Loading branch information
sbrannen committed Mar 16, 2022
1 parent c462fe3 commit c9cd53f
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -92,7 +92,6 @@ private static <C, R> R process(C context, AnnotatedElement source,
}

@Nullable
@SuppressWarnings("deprecation")
private static <C, R> R processClass(C context, Class<?> source,
SearchStrategy searchStrategy, AnnotationsProcessor<C, R> processor) {

Expand Down Expand Up @@ -236,7 +235,6 @@ private static <C, R> R processClassHierarchy(C context, int[] aggregateIndex, C
}

@Nullable
@SuppressWarnings("deprecation")
private static <C, R> R processMethod(C context, Method source,
SearchStrategy searchStrategy, AnnotationsProcessor<C, R> processor) {

Expand Down Expand Up @@ -512,7 +510,6 @@ static boolean hasPlainJavaAnnotationsOnly(Class<?> type) {
return (type.getName().startsWith("java.") || type == Ordered.class);
}

@SuppressWarnings("deprecation")
private static boolean isWithoutHierarchy(AnnotatedElement source, SearchStrategy searchStrategy) {
if (source == Object.class) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,7 @@ enum SearchStrategy {
* need to be meta-annotated with {@link Inherited @Inherited}. When
* searching a {@link Method} source, this strategy is identical to
* {@link #TYPE_HIERARCHY}.
* @deprecated as of Spring Framework 5.3.17; to be removed in Spring Framework 6.0
*/
@Deprecated
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -421,23 +421,20 @@ void typeHierarchyStrategyOnMethodWithGenericParameterNonOverrideScansAnnotation
}

@Test
@SuppressWarnings("deprecation")
void typeHierarchyWithEnclosedStrategyOnEnclosedStaticClassScansAnnotations() {
Class<?> source = AnnotationEnclosingClassSample.EnclosedStatic.EnclosedStaticStatic.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES))
.containsExactly("0:EnclosedThree", "1:EnclosedTwo", "2:EnclosedOne");
}

@Test
@SuppressWarnings("deprecation")
void typeHierarchyWithEnclosedStrategyOnEnclosedInnerClassScansAnnotations() {
Class<?> source = AnnotationEnclosingClassSample.EnclosedInner.EnclosedInnerInner.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES))
.containsExactly("0:EnclosedThree", "1:EnclosedTwo", "2:EnclosedOne");
}

@Test
@SuppressWarnings("deprecation")
void typeHierarchyWithEnclosedStrategyOnMethodHierarchyUsesTypeHierarchyScan() {
Method source = methodFrom(WithHierarchy.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES)).containsExactly(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,15 +712,13 @@ void streamTypeHierarchyFromClassWithInterface() throws Exception {
}

@Test
@SuppressWarnings("deprecation")
void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedInnerClassWithAnnotatedEnclosingClass() {
Stream<Class<?>> classes = MergedAnnotations.from(AnnotatedClass.NonAnnotatedInnerClass.class,
SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType);
assertThat(classes).containsExactly(Component.class, Indexed.class);
}

@Test
@SuppressWarnings("deprecation")
void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedStaticNestedClassWithAnnotatedEnclosingClass() {
Stream<Class<?>> classes = MergedAnnotations.from(AnnotatedClass.NonAnnotatedStaticNestedClass.class,
SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType);
Expand Down

0 comments on commit c9cd53f

Please sign in to comment.