Skip to content

Commit b9b2564

Browse files
committed
Polish "Take MethodType into account to deduce main application class"
See gh-31828
1 parent 10a2471 commit b9b2564

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@ private Class<?> deduceMainApplicationClass() {
285285
}
286286

287287
private Optional<Class<?>> findMainClass(Stream<StackFrame> stack) {
288-
return stack
289-
.filter((frame) -> Objects.equals(frame.getMethodName(), "main")
290-
&& Objects.equals(frame.getMethodType(), MethodType.methodType(void.class, String[].class)))
291-
.findFirst().map(StackWalker.StackFrame::getDeclaringClass);
288+
MethodType mainMethodType = MethodType.methodType(void.class, String[].class);
289+
return stack.filter((frame) -> Objects.equals(frame.getMethodName(), "main"))
290+
.filter((frame) -> Objects.equals(frame.getMethodType(), mainMethodType)).findFirst()
291+
.map(StackWalker.StackFrame::getDeclaringClass);
292292
}
293293

294294
/**

0 commit comments

Comments
 (0)