標籤: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參數和調用的方法的參數是否一致,發現一致後,再檢查調用方法內部,有個null 指標異常(比較低級的錯誤。。)
問題解決。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的一個可能原因