Java Code Examples for proguard.classfile.ClassPool#size()

The following examples show how to use proguard.classfile.ClassPool#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputReader.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Fills the given program class pool and library class pool by reading
 * class files, based on the current configuration.
 */
public void execute(ClassPool programClassPool,
                    ClassPool libraryClassPool) throws IOException
{
    // Check if we have at least some input classes.
    if (configuration.programJars == null)
    {
        throw new IOException("The input is empty. You have to specify one or more '-injars' options");
    }

    // Perform some sanity checks on the class paths.
    checkInputOutput(configuration.libraryJars,
                     configuration.programJars);
    checkInputOutput(configuration.programJars,
                     configuration.programJars);

    WarningPrinter warningPrinter = new WarningPrinter(System.err, configuration.warn);
    WarningPrinter notePrinter    = new WarningPrinter(System.out, configuration.note);

    DuplicateClassPrinter duplicateClassPrinter = new DuplicateClassPrinter(notePrinter);

    // Read the program class files.
    // Prepare a data entry reader to filter all classes,
    // which are then decoded to classes by a class reader,
    // which are then put in the class pool by a class pool filler.
    readInput("Reading program ",
              configuration.programJars,
              new ClassFilter(
              new ClassReader(false,
                              configuration.skipNonPublicLibraryClasses,
                              configuration.skipNonPublicLibraryClassMembers,
                              warningPrinter,
              new ClassPresenceFilter(programClassPool, duplicateClassPrinter,
              new ClassPoolFiller(programClassPool)))));

    // Check if we have at least some input classes.
    if (programClassPool.size() == 0)
    {
        throw new IOException("The input doesn't contain any classes. Did you specify the proper '-injars' options?");
    }

    // Read the library class files, if any.
    if (configuration.libraryJars != null)
    {
        // Prepare a data entry reader to filter all classes,
        // which are then decoded to classes by a class reader,
        // which are then put in the class pool by a class pool filler.
        readInput("Reading library ",
                  configuration.libraryJars,
                  new ClassFilter(
                  new ClassReader(true,
                                  configuration.skipNonPublicLibraryClasses,
                                  configuration.skipNonPublicLibraryClassMembers,
                                  warningPrinter,
                  new ClassPresenceFilter(programClassPool, duplicateClassPrinter,
                  new ClassPresenceFilter(libraryClassPool, duplicateClassPrinter,
                  new ClassPoolFiller(libraryClassPool))))));
    }

    // Print out a summary of the notes, if necessary.
    int noteCount = notePrinter.getWarningCount();
    if (noteCount > 0)
    {
        System.err.println("Note: there were " + noteCount +
                           " duplicate class definitions.");
    }

    // Print out a summary of the warnings, if necessary.
    int warningCount = warningPrinter.getWarningCount();
    if (warningCount > 0)
    {
        System.err.println("Warning: there were " + warningCount +
                           " classes in incorrectly named files.");
        System.err.println("         You should make sure all file names correspond to their class names.");
        System.err.println("         The directory hierarchies must correspond to the package hierarchies.");

        if (!configuration.ignoreWarnings)
        {
            System.err.println("         If you don't mind the mentioned classes not being written out,");
            System.err.println("         you could try your luck using the '-ignorewarnings' option.");
            throw new IOException("Please correct the above warnings first.");
        }
    }
}
 
Example 2
Source File: InputReader.java    From proguard with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Fills the given program class pool and library class pool by reading
 * class files, based on the current configuration.
 */
public void execute(ClassPool programClassPool,
                    ClassPool libraryClassPool) throws IOException
{
    WarningPrinter warningPrinter = new WarningPrinter(System.err, configuration.warn);
    WarningPrinter notePrinter    = new WarningPrinter(System.out, configuration.note);

    DuplicateClassPrinter duplicateClassPrinter = new DuplicateClassPrinter(notePrinter);

    // Read the program class files.
    // Prepare a data entry reader to filter all classes,
    // which are then decoded to classes by a class reader,
    // which are then put in the class pool by a class pool filler.
    readInput("Reading program ",
              configuration.programJars,
              new ClassFilter(
              new ClassReader(false,
                              configuration.skipNonPublicLibraryClasses,
                              configuration.skipNonPublicLibraryClassMembers,
                              warningPrinter,
              new ClassPresenceFilter(programClassPool, duplicateClassPrinter,
              new ClassPoolFiller(programClassPool)))));

    // Check if we have at least some input classes.
    if (programClassPool.size() == 0)
    {
        throw new IOException("The input doesn't contain any classes. Did you specify the proper '-injars' options?");
    }

    // Read the library class files, if any.
    if (configuration.libraryJars != null)
    {
        // Prepare a data entry reader to filter all classes,
        // which are then decoded to classes by a class reader,
        // which are then put in the class pool by a class pool filler.
        readInput("Reading library ",
                  configuration.libraryJars,
                  new ClassFilter(
                  new ClassReader(true,
                                  configuration.skipNonPublicLibraryClasses,
                                  configuration.skipNonPublicLibraryClassMembers,
                                  warningPrinter,
                  new ClassPresenceFilter(programClassPool, duplicateClassPrinter,
                  new ClassPresenceFilter(libraryClassPool, duplicateClassPrinter,
                  new ClassPoolFiller(libraryClassPool))))));
    }

    // Print out a summary of the notes, if necessary.
    int noteCount = notePrinter.getWarningCount();
    if (noteCount > 0)
    {
        System.err.println("Note: there were " + noteCount +
                           " duplicate class definitions.");
        System.err.println("      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)");
    }

    // Print out a summary of the warnings, if necessary.
    int warningCount = warningPrinter.getWarningCount();
    if (warningCount > 0)
    {
        System.err.println("Warning: there were " + warningCount +
                           " classes in incorrectly named files.");
        System.err.println("         You should make sure all file names correspond to their class names.");
        System.err.println("         The directory hierarchies must correspond to the package hierarchies.");
        System.err.println("         (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)");

        if (!configuration.ignoreWarnings)
        {
            System.err.println("         If you don't mind the mentioned classes not being written out,");
            System.err.println("         you could try your luck using the '-ignorewarnings' option.");
            throw new IOException("Please correct the above warnings first.");
        }
    }
}
 
Example 3
Source File: InputReader.java    From bazel with Apache License 2.0 4 votes vote down vote up
/**
 * Fills the given program class pool and library class pool by reading
 * class files, based on the current configuration.
 */
public void execute(ClassPool programClassPool,
                    ClassPool libraryClassPool) throws IOException
{
    WarningPrinter warningPrinter = new WarningPrinter(System.err, configuration.warn);
    WarningPrinter notePrinter    = new WarningPrinter(System.out, configuration.note);

    DuplicateClassPrinter duplicateClassPrinter = new DuplicateClassPrinter(notePrinter);

    // Read the program class files.
    // Prepare a data entry reader to filter all classes,
    // which are then decoded to classes by a class reader,
    // which are then put in the class pool by a class pool filler.
    readInput("Reading program ",
              configuration.programJars,
              new ClassFilter(
              new ClassReader(false,
                              configuration.skipNonPublicLibraryClasses,
                              configuration.skipNonPublicLibraryClassMembers,
                              warningPrinter,
              new ClassPresenceFilter(programClassPool, duplicateClassPrinter,
              new ClassPoolFiller(programClassPool)))));

    // Check if we have at least some input classes.
    if (programClassPool.size() == 0)
    {
        throw new IOException("The input doesn't contain any classes. Did you specify the proper '-injars' options?");
    }

    // Read the library class files, if any.
    if (configuration.libraryJars != null)
    {
        // Prepare a data entry reader to filter all classes,
        // which are then decoded to classes by a class reader,
        // which are then put in the class pool by a class pool filler.
        readInput("Reading library ",
                  configuration.libraryJars,
                  new ClassFilter(
                  new ClassReader(true,
                                  configuration.skipNonPublicLibraryClasses,
                                  configuration.skipNonPublicLibraryClassMembers,
                                  warningPrinter,
                  new ClassPresenceFilter(programClassPool, duplicateClassPrinter,
                  new ClassPresenceFilter(libraryClassPool, duplicateClassPrinter,
                  new ClassPoolFiller(libraryClassPool))))));
    }

    // Print out a summary of the notes, if necessary.
    int noteCount = notePrinter.getWarningCount();
    if (noteCount > 0)
    {
        System.err.println("Note: there were " + noteCount +
                           " duplicate class definitions.");
        System.err.println("      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)");
    }

    // Print out a summary of the warnings, if necessary.
    int warningCount = warningPrinter.getWarningCount();
    if (warningCount > 0)
    {
        System.err.println("Warning: there were " + warningCount +
                           " classes in incorrectly named files.");
        System.err.println("         You should make sure all file names correspond to their class names.");
        System.err.println("         The directory hierarchies must correspond to the package hierarchies.");
        System.err.println("         (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)");

        if (!configuration.ignoreWarnings)
        {
            System.err.println("         If you don't mind the mentioned classes not being written out,");
            System.err.println("         you could try your luck using the '-ignorewarnings' option.");
            throw new IOException("Please correct the above warnings first.");
        }
    }
}