diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 918f2e8dbb..51fc3ea0d3 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -23,6 +23,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -145,7 +146,16 @@ public class AnnotationUtilsTests { assertNull(getAnnotation(bridgeMethod, Order.class)); assertNotNull(findAnnotation(bridgeMethod, Order.class)); - assertNotNull(bridgeMethod.getAnnotation(Transactional.class)); + boolean runningInEclipse = Arrays.stream(new Exception().getStackTrace()) + .anyMatch(element -> element.getClassName().startsWith("org.eclipse.jdt")); + + // As of JDK 8, invoking getAnnotation() on a bridge method actually finds an + // annotation on its 'bridged' method; however, the Eclipse compiler still does + // not properly support this. Thus, we effectively ignore the following assertion + // if the test is currently executing within the Eclipse IDE. + if (!runningInEclipse) { + assertNotNull(bridgeMethod.getAnnotation(Transactional.class)); + } assertNotNull(getAnnotation(bridgeMethod, Transactional.class)); assertNotNull(findAnnotation(bridgeMethod, Transactional.class)); }