All Downloads are FREE. Search and download functionalities are using the official Maven repository.

proguard.classfile.util.InitializationUtil Maven / Gradle / Ivy

Go to download

ProGuardCORE is a free library to read, analyze, modify, and write Java class files.

There is a newer version: 9.1.6
Show newest version
package proguard.classfile.util;

import java.io.*;
import proguard.classfile.*;
import proguard.classfile.visitor.*;
import proguard.io.*;

/**
 * This utility class provides a method to initialize the cached cross-references classes. They are
 * necessary to traverse the class hierarchy efficiently, for example when preverifying code or
 * performing more general partial evaluation.
 */
public class InitializationUtil {
  /**
   * Initializes the cached cross-references of the classes in the given class pools.
   *
   * 

Note: no warnings are given when classes are missing: if you require warnings about missing * classes use {@link InitializationUtil#initialize(ClassPool, ClassPool, WarningPrinter)} * instead. * * @param programClassPool the program class pool, typically with processed classes. * @param libraryClassPool the library class pool, typically with run-time classes. */ public static void initialize(ClassPool programClassPool, ClassPool libraryClassPool) { WarningPrinter nullWarningPrinter = new WarningPrinter( new PrintWriter( new OutputStream() { @Override public void write(int i) {} })); initialize(programClassPool, libraryClassPool, nullWarningPrinter); } /** * Initializes the cached cross-references of the classes in the given class pools. * * @param programClassPool the program class pool, typically with processed classes. * @param libraryClassPool the library class pool, typically with run-time classes. * @param warningPrinter the {@link WarningPrinter} to use for printing warnings about missing * classes. */ public static void initialize( ClassPool programClassPool, ClassPool libraryClassPool, WarningPrinter warningPrinter) { // Initialize the class hierarchies. libraryClassPool.classesAccept( new ClassSuperHierarchyInitializer(programClassPool, libraryClassPool, null, null)); programClassPool.classesAccept( new ClassSuperHierarchyInitializer( programClassPool, libraryClassPool, warningPrinter, warningPrinter)); // Initialize the other references from the program classes. programClassPool.classesAccept( new ClassReferenceInitializer( programClassPool, libraryClassPool, warningPrinter, warningPrinter, warningPrinter, null)); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy