mirror of
https://github.com/FranzHaidnor/haidnorJVM.git
synced 2026-03-13 21:43:42 +08:00
fix:修复编译后参数名称被编译器优化,无法获取到 main 方法的问题
This commit is contained in:
@@ -890,12 +890,15 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
* 获取 main 方法
|
* 获取 main 方法
|
||||||
*/
|
*/
|
||||||
public JavaMethod getMainMethod() {
|
public JavaMethod getMainMethod() {
|
||||||
for (JavaMethod javaMethod : getMethods()) {
|
for (JavaMethod method : getMethods()) {
|
||||||
if (javaMethod.toString().startsWith("public static void main(String[] args)")) {
|
if (method.isPublic()
|
||||||
return javaMethod;
|
&& 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
|
@SneakyThrows
|
||||||
|
|||||||
Reference in New Issue
Block a user