Java Code Examples for proguard.classfile.ProgramClass#superClassConstantAccept()

The following examples show how to use proguard.classfile.ProgramClass#superClassConstantAccept() . 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: ClassSuperHierarchyInitializer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Link to the super class.
    programClass.superClassConstantAccept(this);

    // Link to the interfaces.
    programClass.interfaceConstantsAccept(this);
}
 
Example 2
Source File: HorizontalClassMerger.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    programClass.superClassConstantAccept(new ReferencedClassVisitor(
                                          new SubclassTraveler(
                                          new ProgramClassFilter(
                                          new ClassMerger(programClass,
                                                          allowAccessModification,
                                                          mergeInterfacesAggressively,
                                                          extraClassVisitor)))));
}
 
Example 3
Source File: HorizontalClassMerger.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    programClass.superClassConstantAccept(new ReferencedClassVisitor(
                                          new SubclassTraveler(
                                          new ClassMerger(programClass,
                                                          allowAccessModification,
                                                          mergeInterfacesAggressively,
                                                          extraClassVisitor))));
}
 
Example 4
Source File: HorizontalClassMerger.java    From bazel with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    programClass.superClassConstantAccept(new ReferencedClassVisitor(
                                          new SubclassTraveler(
                                          new ClassMerger(programClass,
                                                          allowAccessModification,
                                                          mergeInterfacesAggressively,
                                                          extraClassVisitor))));
}
 
Example 5
Source File: InterfaceUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    boolean classUsed         = usageMarker.isUsed(programClass);
    boolean classPossiblyUsed = usageMarker.isPossiblyUsed(programClass);

    if (classUsed || classPossiblyUsed)
    {
        // Check if any interfaces are being used.
        boolean oldAnyUsed = anyUsed;
        anyUsed = false;

        programClass.interfaceConstantsAccept(this);

        classUsed |= anyUsed;
        anyUsed = oldAnyUsed;

        // Is this an interface with a preliminary mark?
        if (classPossiblyUsed)
        {
            // Should it be included now?
            if (classUsed)
            {
                // At least one if this interface's interfaces is being used.
                // Mark this interface as well.
                usageMarker.markAsUsed(programClass);

                // Mark this interface's name.
                programClass.thisClassConstantAccept(this);

                // Mark the superclass (java/lang/Object).
                programClass.superClassConstantAccept(this);
            }
            else
            {
                // Unmark this interface, so we don't bother looking at it again.
                usageMarker.markAsUnused(programClass);
            }
        }
    }

    // The return value.
    used = classUsed;
}
 
Example 6
Source File: TargetClassChanger.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Change the references of the constant pool.
    programClass.constantPoolEntriesAccept(this);

    // Change the references of the class members.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);

    // Change the references of the attributes.
    programClass.attributesAccept(this);

    // Is the class itself being retargeted?
    Clazz targetClass = ClassMerger.getTargetClass(programClass);
    if (targetClass != null)
    {
        // Restore the class name. We have to add a new class entry
        // to avoid an existing entry with the same name being reused. The
        // names have to be fixed later, based on their referenced classes.
        programClass.u2thisClass =
            addNewClassConstant(programClass,
                                programClass.getName(),
                                programClass);

        // This class will loose all its interfaces.
        programClass.u2interfacesCount = 0;

        // This class will loose all its subclasses.
        programClass.subClasses = null;
    }
    else
    {
        // Remove interface classes that are pointing to this class.
        int newInterfacesCount = 0;
        for (int index = 0; index < programClass.u2interfacesCount; index++)
        {
            Clazz interfaceClass = programClass.getInterface(index);
            if (!programClass.equals(interfaceClass))
            {
                programClass.u2interfaces[newInterfacesCount++] =
                    programClass.u2interfaces[index];
            }
        }
        programClass.u2interfacesCount = newInterfacesCount;

        // Update the subclasses of the superclass and interfaces of the
        // target class.
        ConstantVisitor subclassAdder =
            new ReferencedClassVisitor(
            new SubclassFilter(programClass,
            new SubclassAdder(programClass)));

        programClass.superClassConstantAccept(subclassAdder);
        programClass.interfaceConstantsAccept(subclassAdder);

        // TODO: Maybe restore private method references.
    }
}