A possible cause of java.lang.reflect.InvocationTargetException

Source: Internet
Author: User

In StackOverflow there is such a sentence: The Reflection layer wraps any exception InvocationTargetException in a, which lets you say the difference between an Exception actually caused by a failure in the "Reflection call" (maybe your argument list wasn ' t valid, for EXAMPL e) and a failure within the method called

The reflection layer wraps all the exceptions in a invocationtargetexception, which allows you to distinguish between exceptions that are actually caused by a call failure (such as invalid argument list) and the internal error of the calling method .

That's probably what it means, um *~*.

So, I looked at the parameters of the invoke parameter and the calling method are consistent, after the discovery of consistency, and then check inside the calling method, there is a null pointer exception (lower-level error: )

Problem solving. 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  you have   through   use   reflection   call   Add   additional     abstract   level  .   Reflective layer will be any   exception   packing   at  InvocationTargetException ,  let   you   tell   actually   Cause   Exception reflection   Call   (maybe   you   parameters   list   Not   valid for example)   failure   and   internal   failure     Difference   Call   method  

One possible cause of java.lang.reflect.InvocationTargetException

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.