码迷,mamicode.com
首页 > 编程语言 > 详细

引起java.lang.reflect.InvocationTargetException的一个可能原因

时间:2017-10-25 21:20:58      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:use   target   原因   targe   级别   stack   nta   导致   失败   

在stackoverflow中有这样一句话: The reflection layer wraps any exception in an InvocationTargetException, which lets you tell the difference between an exception actually caused by a failure in the reflection call (maybe your argument list wasn‘t valid, for example) and a failure within the method called

翻译一下就是: 反射层将所有的异常都包装在一个InvocationTargetException 中,能使你区分异常的实际上是反射层的引起的一个调用失败(例如参数列表无效)和调用方法内部的错误

大概意思就是这样,嗯*~*

所以,我查看了invoke参数和调用的方法的参数是否一致,发现一致后,再检查调用方法内部,有个空指针异常(比较低级的错误。。)

问题解决。bingo~

You‘ve
 
added
 an 
extra
 
level
 
of
 
abstraction
 
by
 
calling
 the 
method
 
with
 
reflection
 
.
 The 
reflection layer
 
wraps
 
any
 
exception
 
in
 an 
InvocationTargetException
 
,
 which 
lets
 
you
 
tell
 
the
 
difference between
 an exception 
actually
 
caused
 
by
 a 
failure
 
in
 the 
reflection
 
call
 
(maybe
 
your
 
argument
 
list
 
wasn‘t
 
valid
, 
for example)
 
and
 a 
failure
 
within
 the 
method
 
called
 
您已经
 
通过
 
使用
 
反射
 
调用
 
添加
 
额外
 
的
 
抽象
 
级别
 
。
 
反射层
将
任何
 
异常
 
包装
 
在
 
InvocationTargetException
 
,
 
让
 
你
 
告诉
 
实际上
 
导致
 
的
异常
反射
 
调用
 
(也许
 
你
 
参数
 
列表
 
不是
 
有效
的
例如)
 
中
的
失败
 
和
 
内部
 
故障
 
的
 
区别
 
调用
 
方法
 

引起java.lang.reflect.InvocationTargetException的一个可能原因

标签:use   target   原因   targe   级别   stack   nta   导致   失败   

原文地址:http://www.cnblogs.com/awomanofsin/p/7731901.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!