diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index 1346439075..02fa7a0ac9 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -926,13 +926,12 @@ class MergedAnnotationsTests { assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(-1); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); - boolean runningInEclipse = Arrays.stream( - new Exception().getStackTrace()).anyMatch( - element -> element.getClassName().startsWith("org.eclipse.jdt")); + boolean runningInEclipse = StackWalker.getInstance().walk(stream -> + stream.anyMatch(stackFrame -> stackFrame.getClassName().startsWith("org.eclipse.jdt"))); // As of JDK 8, invoking getAnnotation() on a bridge method actually finds an // annotation on its 'bridged' method [1]; however, the Eclipse compiler - // will not support this until Eclipse 4.9 [2]. Thus, we effectively ignore the - // following assertion if the test is currently executing within the Eclipse IDE. + // does not support this [2]. Thus, we effectively ignore the following + // assertion if the test is currently executing within the Eclipse IDE. // [1] https://bugs.openjdk.java.net/browse/JDK-6695379 // [2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=495396 if (!runningInEclipse) {