private int checkClass(final ClassReader reader, Pattern suppressAnnotationsPattern) throws ForbiddenApiException {
    final String className = Type.getObjectType(reader.getClassName()).getClassName();
    final ClassScanner scanner = new ClassScanner(this, forbiddenSignatures, suppressAnnotationsPattern); 
    try {
      reader.accept(scanner, ClassReader.SKIP_FRAMES);
    } catch (RelatedClassLoadingException rcle) {
      final Exception cause = rcle.getException();
      final StringBuilder msg = new StringBuilder()
          .append("Check for forbidden API calls failed while scanning class '")
          .append(className)
          .append('\'');
      final String source = scanner.getSourceFile();
      if (source != null) {
        msg.append(" (").append(source).append(')');
      }
      msg.append(": ").append(cause);
      msg.append(" (while looking up details about referenced class '").append(rcle.getClassName()).append("')");
      assert cause != null && (cause instanceof IOException || cause instanceof ClassNotFoundException);
      throw new ForbiddenApiException(msg.toString(), cause);
    }
    final List<ForbiddenViolation> violations = scanner.getSortedViolations();
    final Pattern splitter = Pattern.compile(Pattern.quote(ForbiddenViolation.SEPARATOR));
    for (final ForbiddenViolation v : violations) {
      for (final String line : splitter.split(v.format(className, scanner.getSourceFile()))) {
        logger.error(line);
      }
    }
    return violations.size();
  }
private int checkClass ( final ClassReader reader , Pattern suppressAnnotationsPattern ) throws ForbiddenApiException { final String className = Type . getObjectType ( reader . getClassName ( ) ) . getClassName ( ) ; final ClassScanner scanner = new ClassScanner ( this , forbiddenSignatures , suppressAnnotationsPattern ) ; try { reader . accept ( scanner , ClassReader . SKIP_FRAMES ) ; } catch ( RelatedClassLoadingException rcle ) { final Exception cause = rcle . getException ( ) ; final StringBuilder msg = new StringBuilder ( ) . append ( "Check for forbidden API calls failed while scanning class '" ) . append ( className ) . append ( '\'' ) ; final String source = scanner . getSourceFile ( ) ; if ( source != null ) { msg . append ( " (" ) . append ( source ) . append ( ')' ) ; } msg . append ( ": " ) . append ( cause ) ; msg . append ( " (while looking up details about referenced class '" ) . append ( rcle . getClassName ( ) ) . append ( "')" ) ; assert cause != null && ( cause instanceof IOException || cause instanceof ClassNotFoundException ) ; throw new ForbiddenApiException ( msg . toString ( ) , cause ) ; } final List < ForbiddenViolation > violations = scanner . getSortedViolations ( ) ; final Pattern splitter = Pattern . compile ( Pattern . quote ( ForbiddenViolation . SEPARATOR ) ) ; for ( final ForbiddenViolation v : violations ) { for ( final String line : splitter . split ( v . format ( className , scanner . getSourceFile ( ) ) ) ) { logger . error ( line ) ; } } return violations . size ( ) ; }
Parses a class and checks for valid method invocations