* @return a result (any Object) that will be passed back to the parent checker. May be null</code>.
*/
protected Object onEndCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations,
MemberDeclaration classMember, Map checkResults )
{
MethodDeclaration handlerMethod = ( MethodDeclaration ) checkResults.get( METHOD_ATTR );
DeclaredType exceptionType = ( DeclaredType ) checkResults.get( TYPE_ATTR );
//
// If either of these are null, then there was another already-reported error (e.g., type was unresolved).
//
if ( handlerMethod == null || exceptionType == null )
{
return null;
}
//
// Make sure the given handler method can catch the right kind of exception.
//
ParameterDeclaration[] parameters = handlerMethod.getParameters();
//
// If the method's arguments are wrong in any way, don't worry about it -- the exception-handler checker will
// report an error.
//
if ( parameters.length > 0 )
{
TypeInstance handledExceptionType = parameters[0].getType();
if ( ! CompilerUtils.isAssignableFrom( handledExceptionType, CompilerUtils.getDeclaration( exceptionType ) ) )
{
addError( annotation, "error.incompatible-exception-handler", handlerMethod.getSimpleName(),
CompilerUtils.getDeclaration( exceptionType ).getQualifiedName() );
}
}
return null;