Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For a particular method, how can I view the checked exceptions in java using reflection?

For a particular method, how can I view the checked exceptions in java using reflection? There does not seem to be support for this in the JDK.

like image 361
Rich Ashworth Avatar asked Dec 20 '25 05:12

Rich Ashworth


1 Answers

Use this method in Method:

public Type[] getGenericExceptionTypes()

Then you have to iterate through the types if you want to separate checked and unchecked exceptions.

like image 184
mprivat Avatar answered Dec 21 '25 20:12

mprivat