What could cause java lang reflect InvocationTargetException

0 votes

I've attempted to comprehend and read about potential causes, but I just don't get it:

I have the following code

try{
 ..
 m.invoke(testObject);
 ..
 } catch(AssertionError e){
 ...
 } catch(Exception e){
 ..
 }

 somewhere:
The problem is that it throws InvocationTargetException rather than the expected exception when it tries to invoke a method (specifically ArrayIndexOutOfBoundsException). Since I already knew what the method was called, I skipped over the method's code and added a try-catch block for the line that was supposed to raise an ArrayIndexOutOfBoundsException; in fact, it did so as expected. But when it rises, it mysteriously transforms into an InvocationTargetException, and in the code above, catch(Exception e), e is actually an InvocationTargetException rather than the anticipated ArrayIndexOutOfBoundsException.
What may result in such behavior, and how can I check for it?

Sep 22, 2022 in Java-Script by Tejashwini
• 3,820 points
1,040 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java-Script

0 votes
1 answer

java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

The "Maven Dependency" must be included to ...READ MORE

answered Sep 20, 2022 in Java-Script by Abhinaya
• 1,160 points
5,003 views
0 votes
0 answers

How can I solve Exception in thread "main" java.lang.NullPointerException error

I am having a problem at a ...READ MORE

Sep 20, 2022 in Java-Script by Tejashwini
• 780 points
381 views
0 votes
0 answers

What is difference between mutable and immutable String in java?

As far as I know, An immutable string ...READ MORE

Sep 22, 2022 in Java-Script by Tejashwini
• 3,820 points
292 views
0 votes
0 answers

in java what does the @ symbol mean?

I am aware of what it implies ...READ MORE

Sep 29, 2022 in Java-Script by Abhinaya
• 1,160 points
364 views
0 votes
1 answer

What is callback function in JavaScript?

callback is not a keyword, its just ...READ MORE

answered Jan 30, 2020 in Java-Script by Niroj
• 82,880 points
17,653 views
0 votes
1 answer

What are XMLHttpRequest Object in Ajax?

 As, you are up to ajax so ...READ MORE

answered Jan 31, 2020 in Java-Script by Niroj
• 82,880 points
1,143 views
0 votes
0 answers

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

This is the exception on getConnection(): java.sql.SQLException: Access denied ...READ MORE

May 16, 2022 in Java by Kichu
• 19,050 points
6,602 views
0 votes
0 answers

Exception in thread "main" java.util.NoSuchElementException

Whenever I run this, the chooseCave() function works fine ...READ MORE

Sep 20, 2022 in Java-Script by Tejashwini
• 780 points
744 views
0 votes
0 answers

How can I solve "java.lang.NoClassDefFoundError"?

I've tried both the examples in Oracle's Java ...READ MORE

Sep 20, 2022 in Java-Script by Tejashwini
• 780 points
625 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 79,463 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP