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

The following examples show how to use proguard.classfile.ProgramClass#methodsAccept() . 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: MemberReferenceFixer.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    stackSizesMayHaveChanged = false;

    // Fix the constant pool entries.
    for (int index = 1; index < programClass.u2constantPoolCount; index++)
    {
        Constant constant = programClass.constantPool[index];
        if (constant != null)
        {
            // Fix the entry, replacing it entirely if needed.
            this.constantIndex = index;

            constant.accept(programClass, this);
        }
    }

    // Fix the class members.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);

    // Fix the attributes.
    programClass.attributesAccept(this);
}
 
Example 2
Source File: ConstantPoolRemapper.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Remap the local constant pool references.
    programClass.u2thisClass  = remapConstantIndex(programClass.u2thisClass);
    programClass.u2superClass = remapConstantIndex(programClass.u2superClass);

    remapConstantIndexArray(programClass.u2interfaces,
                            programClass.u2interfacesCount);

    // Remap the references of the contant pool entries themselves.
    programClass.constantPoolEntriesAccept(this);

    // Remap the references in all fields, methods, and attributes.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);
    programClass.attributesAccept(this);
}
 
Example 3
Source File: AttributeSorter.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Sort the attributes.
    Arrays.sort(programClass.attributes, 0, programClass.u2attributesCount, this);

    // Sort the attributes of the class members.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);
}
 
Example 4
Source File: Utf8UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Mark the UTF-8 entries referenced by the other constant pool entries.
    programClass.constantPoolEntriesAccept(this);

    // Mark the UTF-8 entries referenced by the fields and methods.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);

    // Mark the UTF-8 entries referenced by the attributes.
    programClass.attributesAccept(this);
}
 
Example 5
Source File: ClassRenamer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Rename this class.
    programClass.thisClassConstantAccept(this);

    // Rename the class members.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);
}
 
Example 6
Source File: AttributeShrinker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Compact the array for class attributes.
    programClass.u2attributesCount =
        shrinkArray(programClass.attributes,
                    programClass.u2attributesCount);

    // Compact the attributes in fields, methods, and class attributes,
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);
    programClass.attributesAccept(this);
}
 
Example 7
Source File: ClassReferenceFixer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Fix the constant pool.
    programClass.constantPoolEntriesAccept(this);

    // Fix class members.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);

    // Fix the attributes.
    programClass.attributesAccept(this);
}
 
Example 8
Source File: ClassReferenceInitializer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Initialize the constant pool entries.
    programClass.constantPoolEntriesAccept(this);

    // Initialize all fields and methods.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);

    // Initialize the attributes.
    programClass.attributesAccept(this);
}
 
Example 9
Source File: ClassCleaner.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    clean(programClass);

    programClass.constantPoolEntriesAccept(this);

    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);

    programClass.attributesAccept(this);
}
 
Example 10
Source File: ReferencedClassVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Visit the constant pool entries.
    programClass.constantPoolEntriesAccept(this);

    // Visit the fields and methods.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);

    // Visit the attributes.
    programClass.attributesAccept(this);
}
 
Example 11
Source File: AllAttributeVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    programClass.attributesAccept(attributeVisitor);

    // Visit the attributes further down the class structure, if required.
    if (deep)
    {
        programClass.fieldsAccept(this);
        programClass.methodsAccept(this);
        programClass.attributesAccept(this);
    }
}
 
Example 12
Source File: MappingPrinter.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    String name    = programClass.getName();
    String newName = ClassObfuscator.newClassName(programClass);

    ps.println(ClassUtil.externalClassName(name) +
               " -> " +
               ClassUtil.externalClassName(newName) +
               ":");

    // Print out the class members.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);
}
 
Example 13
Source File: ClassDetailVisitor.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public void visitProgramClass(ProgramClass programClass) {
    programClass.constantPoolEntriesAccept(this);

    programClass.methodsAccept(this);
}
 
Example 14
Source File: AllMemberVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    programClass.fieldsAccept(memberVisitor);
    programClass.methodsAccept(memberVisitor);
}
 
Example 15
Source File: ClassPrinter.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    println("_____________________________________________________________________");
    println(visitorInfo(programClass) + " " +
            "Program class: " + programClass.getName());
    indent();
    println("Superclass:    " + programClass.getSuperName());
    println("Major version: 0x" + Integer.toHexString(ClassUtil.internalMajorClassVersion(programClass.u4version)));
    println("Minor version: 0x" + Integer.toHexString(ClassUtil.internalMinorClassVersion(programClass.u4version)));
    println("Access flags:  0x" + Integer.toHexString(programClass.u2accessFlags));
    println("  = " +
            ((programClass.u2accessFlags & ClassConstants.INTERNAL_ACC_ANNOTATTION) != 0 ? "@ " : "") +
            ClassUtil.externalClassAccessFlags(programClass.u2accessFlags) +
            ((programClass.u2accessFlags & ClassConstants.INTERNAL_ACC_ENUM)      != 0 ? "enum " :
             (programClass.u2accessFlags & ClassConstants.INTERNAL_ACC_INTERFACE) == 0 ? "class " :
                                                                                         "") +
            ClassUtil.externalClassName(programClass.getName()) +
            (programClass.u2superClass == 0 ? "" : " extends " +
            ClassUtil.externalClassName(programClass.getSuperName())));
    outdent();
    println();

    println("Interfaces (count = " + programClass.u2interfacesCount + "):");
    indent();
    programClass.interfaceConstantsAccept(this);
    outdent();
    println();

    println("Constant Pool (count = " + programClass.u2constantPoolCount + "):");
    indent();
    programClass.constantPoolEntriesAccept(this);
    outdent();
    println();

    println("Fields (count = " + programClass.u2fieldsCount + "):");
    indent();
    programClass.fieldsAccept(this);
    outdent();
    println();

    println("Methods (count = " + programClass.u2methodsCount + "):");
    indent();
    programClass.methodsAccept(this);
    outdent();
    println();

    println("Class file attributes (count = " + programClass.u2attributesCount + "):");
    indent();
    programClass.attributesAccept(this);
    outdent();
    println();
}
 
Example 16
Source File: AllMethodVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    programClass.methodsAccept(memberVisitor);
}
 
Example 17
Source File: ProgramClassWriter.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Write the magic number.
    dataOutput.writeInt(programClass.u4magic);

    // Write the version numbers.
    dataOutput.writeShort(ClassUtil.internalMinorClassVersion(programClass.u4version));
    dataOutput.writeShort(ClassUtil.internalMajorClassVersion(programClass.u4version));

    // Write the constant pool.
    dataOutput.writeShort(programClass.u2constantPoolCount);

    programClass.constantPoolEntriesAccept(this);

    // Write the general class information.
    dataOutput.writeShort(programClass.u2accessFlags);
    dataOutput.writeShort(programClass.u2thisClass);
    dataOutput.writeShort(programClass.u2superClass);

    // Write the interfaces.
    dataOutput.writeShort(programClass.u2interfacesCount);

    for (int index = 0; index < programClass.u2interfacesCount; index++)
    {
        dataOutput.writeShort(programClass.u2interfaces[index]);
    }

    // Write the fields.
    dataOutput.writeShort(programClass.u2fieldsCount);

    programClass.fieldsAccept(this);

    // Write the methods.
    dataOutput.writeShort(programClass.u2methodsCount);

    programClass.methodsAccept(this);

    // Write the class attributes.
    dataOutput.writeShort(programClass.u2attributesCount);

    programClass.attributesAccept(this);
}
 
Example 18
Source File: SideEffectMethodMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Go over all methods.
    programClass.methodsAccept(this);
}
 
Example 19
Source File: ClassShrinker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Shrink the arrays for constant pool, interfaces, fields, methods,
    // and class attributes.
    programClass.u2interfacesCount =
        shrinkConstantIndexArray(programClass.constantPool,
                                 programClass.u2interfaces,
                                 programClass.u2interfacesCount);

    // Shrinking the constant pool also sets up an index map.
    programClass.u2constantPoolCount =
        shrinkConstantPool(programClass.constantPool,
                           programClass.u2constantPoolCount);

    programClass.u2fieldsCount =
        shrinkArray(programClass.fields,
                    programClass.u2fieldsCount);

    programClass.u2methodsCount =
        shrinkArray(programClass.methods,
                    programClass.u2methodsCount);

    programClass.u2attributesCount =
        shrinkArray(programClass.attributes,
                    programClass.u2attributesCount);

    // Compact the remaining fields, methods, and attributes,
    // and remap their references to the constant pool.
    programClass.fieldsAccept(this);
    programClass.methodsAccept(this);
    programClass.attributesAccept(this);

    // Remap all constant pool references.
    constantPoolRemapper.setConstantIndexMap(constantIndexMap);
    constantPoolRemapper.visitProgramClass(programClass);

    // Remove the unused interfaces from the class signature.
    programClass.attributesAccept(new SignatureShrinker());

    // Compact the extra field pointing to the subclasses of this class.
    programClass.subClasses =
        shrinkToNewArray(programClass.subClasses);
}
 
Example 20
Source File: ClassStructVisitor.java    From atlas with Apache License 2.0 3 votes vote down vote up
@Override
public void visitProgramClass(ProgramClass programClass) {

    addSuperClass(programClass);

    for (int i = 0; i < programClass.getInterfaceCount(); i++) {
        addInterface(programClass, i);
    }

    programClass.methodsAccept(this);

    programClass.fieldsAccept(this);

}