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

來源:互聯網
上載者:User

標籤: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的一個可能原因

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.