Class IOUtil

java.lang.Object
proguard.io.util.IOUtil

public class IOUtil extends Object
This utility class provides methods to read the classes in jar, zips, aars into a ClassPool and write a ClassPool to a jar.
  • Method Details

    • read

      public static ClassPool read(String fileName, boolean isLibrary) throws IOException
      Reads the classes from the specified jar file and returns them as a class pool.
      Parameters:
      fileName - the file name.
      isLibrary - specifies whether classes should be represented as ProgramClass instances (for processing) or LibraryClass instances (more compact).
      Returns:
      a new class pool with the read classes.
      Throws:
      IOException
    • read

      public static ClassPool read(String fileName, boolean isLibrary, boolean initializeKotlinMetadata) throws IOException
      Reads the classes from the specified jar file and returns them as a class pool.
      Parameters:
      fileName - the file name.
      isLibrary - specifies whether classes should be represented as ProgramClass instances (for processing) or LibraryClass instances (more compact).
      initializeKotlinMetadata - specifies to initialize the Kotlin metadata model.
      Returns:
      a new class pool with the read classes.
      Throws:
      IOException
    • read

      public static ClassPool read(File file, boolean isLibrary) throws IOException
      Reads the classes from the specified jar file and returns them as a class pool.
      Parameters:
      file - the file.
      isLibrary - specifies whether classes should be represented as ProgramClass instances (for processing) or LibraryClass instances (more compact).
      Returns:
      a new class pool with the read classes.
      Throws:
      IOException
    • read

      public static ClassPool read(File file, boolean isLibrary, boolean initializeKotlinMetadata) throws IOException
      Reads the classes from the specified jar file and returns them as a class pool.
      Parameters:
      file - the file.
      isLibrary - specifies whether classes should be represented as ProgramClass instances (for processing) or LibraryClass instances (more compact).
      initializeKotlinMetadata - specifies to initialize the Kotlin metadata model.
      Returns:
      a new class pool with the read classes.
      Throws:
      IOException
    • read

      public static ClassPool read(File file, boolean isLibrary, boolean initializeKotlinMetadata, BiFunction<DataEntryReader,ClassVisitor,DataEntryReader> extraDataEntryReader) throws IOException
      Reads the classes from the specified jar file and returns them as a class pool.
      Parameters:
      file - the name of the file.
      isLibrary - specifies whether classes should be represented as ProgramClass instances (for processing) or LibraryClass instances (more compact).
      initializeKotlinMetadata - specifies to initialize the Kotlin metadata model.
      extraDataEntryReader - Optionally provide a function that wraps the reader in another reader.
      Returns:
      a new class pool with the read classes.
      Throws:
      IOException
    • read

      public static ClassPool read(ClassPath classPath, String classNameFilter, boolean android, boolean isLibrary, boolean skipNonPublicLibraryClasses, boolean skipNonPublicLibraryClassMembers, boolean ignoreStackMapAttributes, BiFunction<DataEntryReader,ClassVisitor,DataEntryReader> extraDataEntryReader) throws IOException
      Reads the classes from the specified jar file and returns them as a class pool.
      Parameters:
      isLibrary - specifies whether classes should be represented as ProgramClass instances (for processing) or LibraryClass instances (more compact).
      extraDataEntryReader - Optionally provide a function that wraps the reader in another reader.
      Returns:
      a new class pool with the read classes.
      Throws:
      IOException
    • read

      public static ClassPool read(ClassPath classPath, String classNameFilter, boolean android, boolean isLibrary, boolean initializeKotlinMetadata, boolean skipNonPublicLibraryClasses, boolean skipNonPublicLibraryClassMembers, boolean ignoreStackMapAttributes, BiFunction<DataEntryReader,ClassVisitor,DataEntryReader> extraDataEntryReader) throws IOException
      Throws:
      IOException
    • writeJar

      public static void writeJar(ClassPool programClassPool, String outputJarFileName) throws IOException
      Writes the classes from the given class pool to a specified jar.
      Parameters:
      programClassPool - the classes to write.
      outputJarFileName - the name of the output jar file.
      Throws:
      IOException
    • writeJar

      public static void writeJar(ClassPool programClassPool, String outputJarFileName, String mainClassName) throws IOException
      Writes the classes from the given class pool to a specified jar.
      Parameters:
      programClassPool - the classes to write.
      outputJarFileName - the name of the output jar file.
      Throws:
      IOException