@ Nullable private Map < String , Set < String > > getConstrainingInfo ( JavaClass cls , Method m ) throws ClassNotFoundException { String methodName = m . getName ( ) ; String methodSig = m . getSignature ( ) ; { // First look for the method in interfaces of the class JavaClass [ ] infClasses = cls . getInterfaces ( ) ; for ( JavaClass infCls : infClasses ) { Method infMethod = findMethod ( infCls , methodName , methodSig ) ; if ( infMethod != null ) { return buildConstrainingInfo ( infCls , infMethod ) ; } Map < String , Set < String > > constrainingExs = getConstrainingInfo ( infCls , m ) ; if ( constrainingExs != null ) { return constrainingExs ; } } } { // Next look at the superclass JavaClass superCls = cls . getSuperClass ( ) ; if ( superCls == null ) { return null ; } Method superMethod = findMethod ( superCls , methodName , methodSig ) ; if ( superMethod != null ) { return buildConstrainingInfo ( superCls , superMethod ) ; } // Otherwise recursively call this on the super class return getConstrainingInfo ( superCls , m ) ; } }
finds the super class or interface that constrains the types of exceptions that can be thrown from the given method