File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
spring-boot-project/spring-boot/src/main/java/org/springframework/boot Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 17
17
package org .springframework .boot ;
18
18
19
19
import java .lang .StackWalker .StackFrame ;
20
+ import java .lang .invoke .MethodType ;
20
21
import java .time .Duration ;
21
22
import java .util .ArrayList ;
22
23
import java .util .Arrays ;
165
166
* @author Brian Clozel
166
167
* @author Ethan Rubinson
167
168
* @author Chris Bono
169
+ * @author Yanming Zhou
168
170
* @since 1.0.0
169
171
* @see #run(Class, String[])
170
172
* @see #run(Class[], String[])
@@ -283,8 +285,10 @@ private Class<?> deduceMainApplicationClass() {
283
285
}
284
286
285
287
private Optional <Class <?>> findMainClass (Stream <StackFrame > stack ) {
286
- return stack .filter ((frame ) -> Objects .equals (frame .getMethodName (), "main" )).findFirst ()
287
- .map (StackWalker .StackFrame ::getDeclaringClass );
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
292
}
289
293
290
294
/**
You can’t perform that action at this time.
0 commit comments