private boolean methodThrowsException ( Method method , Class < ? extends Exception > exceptionType ) { // Check whether the method throws an exception of the specified type for ( Class < ? > thrownType : method . getExceptionTypes ( ) ) { if ( exceptionType . isAssignableFrom ( thrownType ) ) return true ; } // No such exception is declared to be thrown return false ; }
Returns whether the given method throws the specified exception type including any subclasses of that type .