proguard.classfile.io.ProgramClassWriter Java Examples

The following examples show how to use proguard.classfile.io.ProgramClassWriter. 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: ClassRewriter.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void read(DataEntry dataEntry) throws IOException
{
    String inputName = dataEntry.getName();
    String className = inputName.substring(0, inputName.length() - ClassConstants.CLASS_FILE_EXTENSION.length());

    // Find the modified class corrsponding to the input entry.
    ProgramClass programClass = (ProgramClass)classPool.getClass(className);
    if (programClass != null)
    {
        // Rename the data entry if necessary.
        String newClassName = programClass.getName();
        if (!className.equals(newClassName))
        {
            dataEntry = new RenamedDataEntry(dataEntry, newClassName + ClassConstants.CLASS_FILE_EXTENSION);
        }

        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(dataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
}
 
Example #2
Source File: ClassRewriter.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void read(DataEntry dataEntry) throws IOException
{
    String inputName = dataEntry.getName();
    String className = inputName.substring(0, inputName.length() - ClassConstants.CLASS_FILE_EXTENSION.length());

    // Find the modified class corrsponding to the input entry.
    ProgramClass programClass = (ProgramClass)classPool.getClass(className);
    if (programClass != null)
    {
        // Rename the data entry if necessary.
        String newClassName = programClass.getName();
        if (!className.equals(newClassName))
        {
            dataEntry = new RenamedDataEntry(dataEntry, newClassName + ClassConstants.CLASS_FILE_EXTENSION);
        }

        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(dataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
}
 
Example #3
Source File: DataEntryClassWriter.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Rename the data entry if necessary.
    String    actualClassName = programClass.getName();
    DataEntry actualDataEntry =
        new RenamedDataEntry(templateDataEntry,
                             actualClassName + ClassConstants.CLASS_FILE_EXTENSION);

    try
    {
        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(actualDataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
    catch (IOException e)
    {
        throw new RuntimeException("Can't write program class ["+actualClassName+"] to ["+actualDataEntry+"] ("+e.getMessage()+")", e);
    }
}
 
Example #4
Source File: ClassRewriter.java    From bazel with Apache License 2.0 5 votes vote down vote up
public void read(DataEntry dataEntry) throws IOException
{
    String inputName = dataEntry.getName();
    String className = inputName.substring(0, inputName.length() - ClassConstants.CLASS_FILE_EXTENSION.length());

    // Find the modified class corrsponding to the input entry.
    ProgramClass programClass = (ProgramClass)classPool.getClass(className);
    if (programClass != null)
    {
        // Rename the data entry if necessary.
        String newClassName = programClass.getName();
        if (!className.equals(newClassName))
        {
            dataEntry = new RenamedDataEntry(dataEntry, newClassName + ClassConstants.CLASS_FILE_EXTENSION);
        }

        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(dataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
}
 
Example #5
Source File: DataEntryClassWriter.java    From bazel with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Rename the data entry if necessary.
    String    actualClassName = programClass.getName();
    DataEntry actualDataEntry =
        new RenamedDataEntry(templateDataEntry,
                             actualClassName + ClassConstants.CLASS_FILE_EXTENSION);

    try
    {
        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(actualDataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
    catch (IOException e)
    {
        throw new RuntimeException("Can't write program class ["+actualClassName+"] to ["+actualDataEntry+"] ("+e.getMessage()+")", e);
    }
}