//调用动态执行方法
object = BuilderTestObject.callMeth(className, methodName, paramTypes, paramValues);
}
catch (IllegalArgumentException e)
{
errMsg = e.getMessage();
}
catch (SecurityException e)
{
errMsg = e.getMessage();
}
catch (IllegalAccessException e)
{
errMsg = e.getMessage();
}
catch (InvocationTargetException e)
{
//因为默认情况为null,所以必须认为处理
Throwable targetEx = e.getTargetException();
if (targetEx != null)
{
errMsg = targetEx.getMessage();
}
}
文章来源于领测软件测试网 https://www.ltesting.net/