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 in Java-Script by Tejashwini
• 1,960 points
7 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
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 in Java-Script by Tejashwini
• 540 points
12 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 in Java-Script by Tejashwini
• 1,960 points
12 views
0 votes
0 answers

in java what does the @ symbol mean?

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

4 days ago in Java-Script by Abhinaya
• 1,160 points
8 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,780 points
11,310 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,780 points
538 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 in Java by Kichu
• 19,040 points
2,641 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 in Java-Script by Tejashwini
• 540 points
17 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 in Java-Script by Tejashwini
• 540 points
13 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 64,781 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