mirror of
https://github.com/FranzHaidnor/haidnorJVM.git
synced 2026-03-13 13:33:42 +08:00
fix:修复编译后参数名称被编译器优化,无法获取到 main 方法的问题
This commit is contained in:
@@ -890,12 +890,15 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
||||
* 获取 main 方法
|
||||
*/
|
||||
public JavaMethod getMainMethod() {
|
||||
for (JavaMethod javaMethod : getMethods()) {
|
||||
if (javaMethod.toString().startsWith("public static void main(String[] args)")) {
|
||||
return javaMethod;
|
||||
for (JavaMethod method : getMethods()) {
|
||||
if (method.isPublic()
|
||||
&& method.isStatic()
|
||||
&& method.getName().equals("main")
|
||||
&& method.getSignature().equals("([Ljava/lang/String;)V")) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
throw new RuntimeException("can not found main() method");
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
||||
Reference in New Issue
Block a user