Java Code Examples for proguard.classfile.constant.visitor.ConstantVisitor

The following examples show how to use proguard.classfile.constant.visitor.ConstantVisitor. These examples are extracted from open source projects. 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 Project: bazel   Source File: ProgramClass.java    License: Apache License 2.0 5 votes vote down vote up
public void interfaceConstantsAccept(ConstantVisitor constantVisitor)
{
    for (int index = 0; index < u2interfacesCount; index++)
    {
        constantPool[u2interfaces[index]].accept(this, constantVisitor);
    }
}
 
Example 2
Source Project: bazel   Source File: ProgramClass.java    License: Apache License 2.0 5 votes vote down vote up
public void superClassConstantAccept(ConstantVisitor constantVisitor)
{
    if (u2superClass != 0)
    {
        constantPool[u2superClass].accept(this, constantVisitor);
    }
}
 
Example 3
Source Project: java-n-IDE-for-Android   Source File: InnerClassesInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to the class constant of the
 * outer class, if any.
 */
public void outerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    if (u2outerClassIndex != 0)
    {
        clazz.constantPoolEntryAccept(u2outerClassIndex,
                                             constantVisitor);
    }
}
 
Example 4
Source Project: java-n-IDE-for-Android   Source File: InnerClassesInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to the Utf8 constant of the
 * inner name, if any.
 */
public void innerNameConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    if (u2innerNameIndex != 0)
    {
        clazz.constantPoolEntryAccept(u2innerNameIndex,
                                             constantVisitor);
    }
}
 
Example 5
/**
 * Applies the given constant pool visitor to all exception class pool info
 * entries.
 */
public void exceptionEntriesAccept(ProgramClass programClass, ConstantVisitor constantVisitor)
{
    for (int index = 0; index < u2exceptionIndexTableLength; index++)
    {
        programClass.constantPoolEntryAccept(u2exceptionIndexTable[index],
                                             constantVisitor);
    }
}
 
Example 6
Source Project: java-n-IDE-for-Android   Source File: ProgramClass.java    License: Apache License 2.0 5 votes vote down vote up
public void constantPoolEntriesAccept(ConstantVisitor constantVisitor)
{
    for (int index = 1; index < u2constantPoolCount; index++)
    {
        if (constantPool[index] != null)
        {
            constantPool[index].accept(this, constantVisitor);
        }
    }
}
 
Example 7
Source Project: java-n-IDE-for-Android   Source File: ProgramClass.java    License: Apache License 2.0 5 votes vote down vote up
public void superClassConstantAccept(ConstantVisitor constantVisitor)
{
    if (u2superClass != 0)
    {
        constantPool[u2superClass].accept(this, constantVisitor);
    }
}
 
Example 8
Source Project: bazel   Source File: InnerClassesInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to the Utf8 constant of the
 * inner name, if any.
 */
public void innerNameConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    if (u2innerNameIndex != 0)
    {
        clazz.constantPoolEntryAccept(u2innerNameIndex, constantVisitor);
    }
}
 
Example 9
Source Project: bazel   Source File: ExceptionsAttribute.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to all exception class pool info
 * entries.
 */
public void exceptionEntriesAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    for (int index = 0; index < u2exceptionIndexTableLength; index++)
    {
        clazz.constantPoolEntryAccept(u2exceptionIndexTable[index],
                                      constantVisitor);
    }
}
 
Example 10
Source Project: bazel   Source File: BootstrapMethodInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to the argument constants of the
 * bootstrap method.
 */
public void methodArgumentsAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    for (int index = 0; index < u2methodArgumentCount; index++)
    {
        clazz.constantPoolEntryAccept(u2methodArguments[index],
                                      constantVisitor);
    }
}
 
Example 11
Source Project: proguard   Source File: InnerClassesInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to the class constant of the
 * inner class, if any.
 */
public void innerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    if (u2innerClassIndex != 0)
    {
        clazz.constantPoolEntryAccept(u2innerClassIndex, constantVisitor);
    }
}
 
Example 12
Source Project: proguard   Source File: InnerClassesInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to the class constant of the
 * outer class, if any.
 */
public void outerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    if (u2outerClassIndex != 0)
    {
        clazz.constantPoolEntryAccept(u2outerClassIndex, constantVisitor);
    }
}
 
Example 13
Source Project: proguard   Source File: InnerClassesInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to the Utf8 constant of the
 * inner name, if any.
 */
public void innerNameConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    if (u2innerNameIndex != 0)
    {
        clazz.constantPoolEntryAccept(u2innerNameIndex, constantVisitor);
    }
}
 
Example 14
Source Project: proguard   Source File: ExceptionsAttribute.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to all exception class pool info
 * entries.
 */
public void exceptionEntriesAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    for (int index = 0; index < u2exceptionIndexTableLength; index++)
    {
        clazz.constantPoolEntryAccept(u2exceptionIndexTable[index],
                                      constantVisitor);
    }
}
 
Example 15
Source Project: bazel   Source File: ProgramClass.java    License: Apache License 2.0 5 votes vote down vote up
public void constantPoolEntriesAccept(ConstantVisitor constantVisitor)
{
    for (int index = 1; index < u2constantPoolCount; index++)
    {
        if (constantPool[index] != null)
        {
            constantPool[index].accept(this, constantVisitor);
        }
    }
}
 
Example 16
Source Project: proguard   Source File: ProgramClass.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void superClassConstantAccept(ConstantVisitor constantVisitor)
{
    if (u2superClass != 0)
    {
        constantPool[u2superClass].accept(this, constantVisitor);
    }
}
 
Example 17
Source Project: proguard   Source File: ProgramClass.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void interfaceConstantsAccept(ConstantVisitor constantVisitor)
{
    for (int index = 0; index < u2interfacesCount; index++)
    {
        constantPool[u2interfaces[index]].accept(this, constantVisitor);
    }
}
 
Example 18
Source Project: bazel   Source File: InnerClassesInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given constant pool visitor to the class constant of the
 * inner class, if any.
 */
public void innerClassConstantAccept(Clazz clazz, ConstantVisitor constantVisitor)
{
    if (u2innerClassIndex != 0)
    {
        clazz.constantPoolEntryAccept(u2innerClassIndex, constantVisitor);
    }
}
 
Example 19
Source Project: proguard   Source File: ClassShrinker.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates an array marking unused constant pool entries for all the
 * elements in the given array of constant pool indices, pointing to
 * class constants of interfaces.
 * @return an array of flags indicating unused elements.
 */
private boolean[] shrinkInterfaceFlags(ProgramClass programClass)
{
    Constant[] constantPool    = programClass.constantPool;
    int[]      interfaces      = programClass.u2interfaces;
    int        interfacesCount = programClass.u2interfacesCount;

    // Collect the names of all indirectly implemented interfaces, unless
    // they are kept or the class itself is kept. That avoids problems if
    // some code applies reflection to the list of interfaces.
    Set indirectlyImplementedInterfaces = new HashSet();

    if ((programClass.getProcessingFlags() & ProcessingFlags.DONT_SHRINK) == 0)
    {
        ConstantVisitor interfaceNameCollector =
            new ReferencedClassVisitor(
            new UsedClassFilter(usageMarker,
            new ClassHierarchyTraveler(false, true, true, false,
            new ProgramClassFilter(
            new UsedClassFilter(usageMarker,
            new ClassAccessFilter(AccessConstants.INTERFACE, 0,
            new ClassProcessingFlagFilter(0, ProcessingFlags.DONT_SHRINK,
            new ClassNameCollector(indirectlyImplementedInterfaces))))))));

        programClass.superClassConstantAccept(interfaceNameCollector);
        programClass.interfaceConstantsAccept(interfaceNameCollector);
    }

    boolean[] unused = new boolean[interfacesCount];

    // Remember the unused or unnecessary constants.
    for (int index = 0; index < interfacesCount; index++)
    {
        // The interface may be unused, or it may be unnecessary in the
        // list of implemented interfaces, if a superclass/interface
        // already implements it.
        ClassConstant interfaceClassConstant =
            (ClassConstant)constantPool[interfaces[index]];
        String interfaceClassName =
            interfaceClassConstant.getName(programClass);

        if (!usageMarker.isUsed(interfaceClassConstant) ||
            indirectlyImplementedInterfaces.contains(interfaceClassName))
        {
            unused[index] = true;
        }
    }

    return unused;
}
 
Example 20
Source Project: bazel   Source File: LibraryClass.java    License: Apache License 2.0 4 votes vote down vote up
public void thisClassConstantAccept(ConstantVisitor constantVisitor)
{
    // This class doesn't keep references to its constant pool entries.
}
 
Example 21
Source Project: java-n-IDE-for-Android   Source File: IntegerConstant.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(Clazz clazz, ConstantVisitor constantVisitor)
{
    constantVisitor.visitIntegerConstant(clazz, this);
}
 
Example 22
Source Project: bazel   Source File: NameAndTypeConstant.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(Clazz clazz, ConstantVisitor constantVisitor)
{
    constantVisitor.visitNameAndTypeConstant(clazz, this);
}
 
Example 23
Source Project: java-n-IDE-for-Android   Source File: LongConstant.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(Clazz clazz, ConstantVisitor constantVisitor)
{
    constantVisitor.visitLongConstant(clazz, this);
}
 
Example 24
Source Project: bazel   Source File: FloatConstant.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(Clazz clazz, ConstantVisitor constantVisitor)
{
    constantVisitor.visitFloatConstant(clazz, this);
}
 
Example 25
Source Project: java-n-IDE-for-Android   Source File: Utf8Constant.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(Clazz clazz, ConstantVisitor constantVisitor)
{
    constantVisitor.visitUtf8Constant(clazz, this);
}
 
Example 26
Source Project: java-n-IDE-for-Android   Source File: DoubleConstant.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(Clazz clazz, ConstantVisitor constantVisitor)
{
    constantVisitor.visitDoubleConstant(clazz, this);
}
 
Example 27
Source Project: bazel   Source File: ProgramClass.java    License: Apache License 2.0 4 votes vote down vote up
public void constantPoolEntryAccept(int index, ConstantVisitor constantVisitor)
{
    constantPool[index].accept(this, constantVisitor);
}
 
Example 28
Source Project: java-n-IDE-for-Android   Source File: FloatConstant.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(Clazz clazz, ConstantVisitor constantVisitor)
{
    constantVisitor.visitFloatConstant(clazz, this);
}
 
Example 29
Source Project: bazel   Source File: InterfaceMethodrefConstant.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(Clazz clazz, ConstantVisitor constantVisitor)
{
    constantVisitor.visitInterfaceMethodrefConstant(clazz, this);
}
 
Example 30
Source Project: java-n-IDE-for-Android   Source File: ClassConstant.java    License: Apache License 2.0 4 votes vote down vote up
public void accept(Clazz clazz, ConstantVisitor constantVisitor)
{
    constantVisitor.visitClassConstant(clazz, this);
}