Avoid unnecessary introspection on methods and meta-annotations

Issue: SPR-16667
This commit is contained in:
Juergen Hoeller
2018-03-31 00:18:14 +02:00
parent b1048975d2
commit 4da27c2a73
5 changed files with 80 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -36,6 +36,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.subpackage.NonPublicAnnotatedClass;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
@@ -1541,6 +1542,13 @@ public class AnnotationUtilsTests {
assertArrayEquals(new char[] { 'x', 'y', 'z' }, chars);
}
@Test
public void interfaceWithAnnotatedMethods() {
assertFalse(AnnotationUtils.isInterfaceWithAnnotatedMethods(NonAnnotatedInterface.class));
assertTrue(AnnotationUtils.isInterfaceWithAnnotatedMethods(AnnotatedInterface.class));
assertFalse(AnnotationUtils.isInterfaceWithAnnotatedMethods(NullableAnnotatedInterface.class));
}
@SafeVarargs
static <T> T[] asArray(T... arr) {
@@ -1634,6 +1642,12 @@ public class AnnotationUtilsTests {
void fromInterfaceImplementedByRoot();
}
public interface NullableAnnotatedInterface {
@Nullable
void fromInterfaceImplementedByRoot();
}
public static class Root implements AnnotatedInterface {
@Order(27)