Revert "Merge pull request #31828 from quaff"

This reverts commit 68fc87bc7f.

See gh-31828
pull/31863/head
Stephane Nicoll 2 years ago
parent 24cf5fff84
commit a0dd6ef3b1

@ -17,7 +17,6 @@
package org.springframework.boot; package org.springframework.boot;
import java.lang.StackWalker.StackFrame; import java.lang.StackWalker.StackFrame;
import java.lang.invoke.MethodType;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -166,7 +165,6 @@ import org.springframework.util.StringUtils;
* @author Brian Clozel * @author Brian Clozel
* @author Ethan Rubinson * @author Ethan Rubinson
* @author Chris Bono * @author Chris Bono
* @author Yanming Zhou
* @since 1.0.0 * @since 1.0.0
* @see #run(Class, String[]) * @see #run(Class, String[])
* @see #run(Class[], String[]) * @see #run(Class[], String[])
@ -285,9 +283,7 @@ public class SpringApplication {
} }
private Optional<Class<?>> findMainClass(Stream<StackFrame> stack) { private Optional<Class<?>> findMainClass(Stream<StackFrame> stack) {
MethodType mainMethodType = MethodType.methodType(void.class, String[].class); return stack.filter((frame) -> Objects.equals(frame.getMethodName(), "main")).findFirst()
return stack.filter((frame) -> Objects.equals(frame.getMethodName(), "main"))
.filter((frame) -> Objects.equals(frame.getMethodType(), mainMethodType)).findFirst()
.map(StackWalker.StackFrame::getDeclaringClass); .map(StackWalker.StackFrame::getDeclaringClass);
} }

Loading…
Cancel
Save