From 8e5f39b439ae9eb140949fc7d3c937c77f90ea85 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 15 Oct 2023 15:54:51 +0200 Subject: [PATCH] Align with StackWalker use in MergedAnnotationsTests.getFromMethodWithBridgeMethod() --- .../core/annotation/AnnotationUtilsTests.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 f181a1af13..840b3f4a5f 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 @@ -24,7 +24,6 @@ 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; @@ -160,9 +159,8 @@ class AnnotationUtilsTests { assertThat(getAnnotation(bridgeMethod, Order.class)).isNull(); assertThat(findAnnotation(bridgeMethod, Order.class)).isNotNull(); - 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