catch exceptions for new

This commit is contained in:
金戟 2020-05-14 18:45:12 +08:00
parent 3e90422cb6
commit 6ea3072f76

View File

@ -42,7 +42,11 @@ public class StaticNewClassGenerator {
.beginControlFlow("for (Object o : args)")
.addStatement("pts.add(o.getClass())")
.endControlFlow()
.addStatement("return type.getConstructor(pts.toArray(new Class[0])).newInstance(args)");
.beginControlFlow("try")
.addStatement("return type.getConstructor(pts.toArray(new Class[0])).newInstance(args)")
.nextControlFlow("catch (Exception e)")
.addStatement("return null")
.endControlFlow();
}
}