mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-10 20:30:11 +08:00
catch exceptions for new
This commit is contained in:
parent
3e90422cb6
commit
6ea3072f76
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user