Troubleshooting
Locating Methods
Q1: | Why can't I find the method I'm looking for? |
If the method was defined in a superclass of the one you're using, make sure you use getMethod instead of getDeclaredMethod. Second, double-check the array of method parameters and make sure you are using the correct types. Remember to use .TYPE to get native types. |
Exceptions
Q1: | When a method throws an exception, why do I get an InvocationTargetException instead of the real exception? |
That's just the way Reflection works. Call getTargetException on the InvocationTargetException to get the underlying exception. |
Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.