提交者
Gitee
newInstance() 已弃用,使用clazz.getDeclaredConstructor().newInstance()
This method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. The Constructor.newInstance method avoids this problem by wrapping any exception thrown by the constructor in a (checked) InvocationTargetException. The call clazz.newInstance() can be replaced by clazz.getDeclaredConstructor().newInstance() The latter sequence of calls is inferred to be able to throw the additional exception types InvocationTargetException and NoSuchMethodException. Both of these exception types are subclasses of ReflectiveOperationException. Signed-off-by: Nymph2333 <498092988@qq.com>
正在显示
1 个修改的文件
包含
1 行增加
和
1 行删除
| @@ -34,7 +34,7 @@ public class JobInvokeUtil | @@ -34,7 +34,7 @@ public class JobInvokeUtil | ||
| 34 | } | 34 | } |
| 35 | else | 35 | else |
| 36 | { | 36 | { |
| 37 | - Object bean = Class.forName(beanName).newInstance(); | 37 | + Object bean = Class.forName(beanName).getDeclaredConstructor().newInstance(); |
| 38 | invokeMethod(bean, methodName, methodParams); | 38 | invokeMethod(bean, methodName, methodParams); |
| 39 | } | 39 | } |
| 40 | } | 40 | } |
-
请 注册 或 登录 后发表评论