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

The following examples show how to use proguard.classfile.ProgramClass#constantPoolEntriesAccept() . 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: 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 2
Source File: NonPrivateMemberMarker.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Mark all referenced class members in different classes.
    programClass.constantPoolEntriesAccept(this);

    // Explicitly mark the <clinit> method.
    programClass.methodAccept(ClassConstants.INTERNAL_METHOD_NAME_CLINIT,
                              ClassConstants.INTERNAL_METHOD_TYPE_CLINIT,
                              this);

    // Explicitly mark the parameterless <init> method.
    programClass.methodAccept(ClassConstants.INTERNAL_METHOD_NAME_INIT,
                              ClassConstants.INTERNAL_METHOD_TYPE_INIT,
                              this);

    // Mark all methods that may have implementations.
    programClass.methodsAccept(filteredMethodMarker);
}
 
Example 3
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 4
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 5
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 6
Source File: StringSharer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Replace name strings in the constant pool by shared strings.
    programClass.constantPoolEntriesAccept(this);

    // Replace attribute name strings in the constant pool by internalized
    // strings.
    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: 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 9
Source File: NameAndTypeUsageMarker.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 NameAndType entries referenced by all other constant pool
    // entries.
    programClass.constantPoolEntriesAccept(this);

    // Mark the NameAndType entries referenced by all EnclosingMethod
    // attributes.
    programClass.attributesAccept(this);
}
 
Example 10
Source File: AllConstantVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    programClass.constantPoolEntriesAccept(constantVisitor);
}
 
Example 11
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 12
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 13
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.
    }
}
 
Example 14
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 15
Source File: AbstractClasslVisitor.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public void visitProgramClass(ProgramClass programClass) {
    programClass.constantPoolEntriesAccept(this);
}