private void checkForSubscribersToSkip ( Messager messager , String myPackage ) { for ( TypeElement skipCandidate : methodsByClass . keySet ( ) ) { TypeElement subscriberClass = skipCandidate ; while ( subscriberClass != null ) { if ( ! isVisible ( myPackage , subscriberClass ) ) { boolean added = classesToSkip . add ( skipCandidate ) ; if ( added ) { String msg ; if ( subscriberClass . equals ( skipCandidate ) ) { msg = "Falling back to reflection because class is not public" ; } else { msg = "Falling back to reflection because " + skipCandidate + " has a non-public super class" ; } messager . printMessage ( Diagnostic . Kind . NOTE , msg , subscriberClass ) ; } break ; } List < ExecutableElement > methods = methodsByClass . get ( subscriberClass ) ; if ( methods != null ) { for ( ExecutableElement method : methods ) { String skipReason = null ; VariableElement param = method . getParameters ( ) . get ( 0 ) ; TypeMirror typeMirror = getParamTypeMirror ( param , messager ) ; if ( ! ( typeMirror instanceof DeclaredType ) || ! ( ( ( DeclaredType ) typeMirror ) . asElement ( ) instanceof TypeElement ) ) { skipReason = "event type cannot be processed" ; } if ( skipReason == null ) { TypeElement eventTypeElement = ( TypeElement ) ( ( DeclaredType ) typeMirror ) . asElement ( ) ; if ( ! isVisible ( myPackage , eventTypeElement ) ) { skipReason = "event type is not public" ; } } if ( skipReason != null ) { boolean added = classesToSkip . add ( skipCandidate ) ; if ( added ) { String msg = "Falling back to reflection because " + skipReason ; if ( ! subscriberClass . equals ( skipCandidate ) ) { msg += " (found in super class for " + skipCandidate + ")" ; } messager . printMessage ( Diagnostic . Kind . NOTE , msg , param ) ; } break ; } } } subscriberClass = getSuperclass ( subscriberClass ) ; } } }
Subscriber classes should be skipped if their class or any involved event class are not visible to the index .