Java Code Examples for proguard.classfile.constant.FieldrefConstant

The following examples show how to use proguard.classfile.constant.FieldrefConstant. 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
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    // Pop the field value, if applicable.
    if (!isLoad)
    {
        setFieldValue(clazz, fieldrefConstant, stack.pop());
    }

    // Pop the reference value, if applicable.
    if (!isStatic)
    {
        setFieldClassValue(clazz, fieldrefConstant, stack.apop());
    }

    // Push the field value, if applicable.
    if (isLoad)
    {
        String type = fieldrefConstant.getType(clazz);

        stack.push(getFieldValue(clazz, fieldrefConstant, type));
    }
}
 
Example 2
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    // Do we know the referenced field?
    Member referencedMember = fieldrefConstant.referencedMember;
    if (referencedMember != null)
    {
        Clazz referencedClass = fieldrefConstant.referencedClass;

        // Does it have a new name or type?
        String newName = referencedMember.getName(referencedClass);
        String newType = referencedMember.getDescriptor(referencedClass);

        if (!fieldrefConstant.getName(clazz).equals(newName) ||
            !fieldrefConstant.getType(clazz).equals(newType))
        {
            if (DEBUG)
            {
                debug(clazz, fieldrefConstant, referencedClass, referencedMember);
            }

            // Update the name and type index.
            fieldrefConstant.u2nameAndTypeIndex =
                new ConstantPoolEditor((ProgramClass)clazz).addNameAndTypeConstant(newName, newType);
        }
    }
}
 
Example 3
Source Project: java-n-IDE-for-Android   Source File: LibraryClassReader.java    License: Apache License 2.0 6 votes vote down vote up
private Constant createConstant()
{
    int u1tag = dataInput.readUnsignedByte();

    switch (u1tag)
    {
        case ClassConstants.CONSTANT_Utf8:               return new Utf8Constant();
        case ClassConstants.CONSTANT_Integer:            return new IntegerConstant();
        case ClassConstants.CONSTANT_Float:              return new FloatConstant();
        case ClassConstants.CONSTANT_Long:               return new LongConstant();
        case ClassConstants.CONSTANT_Double:             return new DoubleConstant();
        case ClassConstants.CONSTANT_String:             return new StringConstant();
        case ClassConstants.CONSTANT_Fieldref:           return new FieldrefConstant();
        case ClassConstants.CONSTANT_Methodref:          return new MethodrefConstant();
        case ClassConstants.CONSTANT_InterfaceMethodref: return new InterfaceMethodrefConstant();
        case ClassConstants.CONSTANT_Class:              return new ClassConstant();
        case ClassConstants.CONSTANT_NameAndType:        return new NameAndTypeConstant();

        default: throw new RuntimeException("Unknown constant type ["+u1tag+"] in constant pool");
    }
}
 
Example 4
Source Project: java-n-IDE-for-Android   Source File: ProgramClassReader.java    License: Apache License 2.0 6 votes vote down vote up
private Constant createConstant()
{
    int u1tag = dataInput.readUnsignedByte();

    switch (u1tag)
    {
        case ClassConstants.CONSTANT_Utf8:               return new Utf8Constant();
        case ClassConstants.CONSTANT_Integer:            return new IntegerConstant();
        case ClassConstants.CONSTANT_Float:              return new FloatConstant();
        case ClassConstants.CONSTANT_Long:               return new LongConstant();
        case ClassConstants.CONSTANT_Double:             return new DoubleConstant();
        case ClassConstants.CONSTANT_String:             return new StringConstant();
        case ClassConstants.CONSTANT_Fieldref:           return new FieldrefConstant();
        case ClassConstants.CONSTANT_Methodref:          return new MethodrefConstant();
        case ClassConstants.CONSTANT_InterfaceMethodref: return new InterfaceMethodrefConstant();
        case ClassConstants.CONSTANT_Class:              return new ClassConstant();
        case ClassConstants.CONSTANT_NameAndType:        return new NameAndTypeConstant();

        default: throw new RuntimeException("Unknown constant type ["+u1tag+"] in constant pool");
    }
}
 
Example 5
Source Project: java-n-IDE-for-Android   Source File: ClassPrinter.java    License: Apache License 2.0 5 votes vote down vote up
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    println(visitorInfo(fieldrefConstant) + " Fieldref [" +
            clazz.getClassName(fieldrefConstant.u2classIndex)  + "." +
            clazz.getName(fieldrefConstant.u2nameAndTypeIndex) + " " +
            clazz.getType(fieldrefConstant.u2nameAndTypeIndex) + "]");
}
 
Example 6
Source Project: java-n-IDE-for-Android   Source File: ConstantAdder.java    License: Apache License 2.0 5 votes vote down vote up
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    // First add the referenced class constant, with its own referenced class.
    clazz.constantPoolEntryAccept(fieldrefConstant.u2classIndex, this);

    // Then add the actual field reference constant, with its referenced
    // class and class member.
    constantIndex =
        constantPoolEditor.addFieldrefConstant(constantIndex,
                                               fieldrefConstant.getName(clazz),
                                               fieldrefConstant.getType(clazz),
                                               fieldrefConstant.referencedClass,
                                               fieldrefConstant.referencedMember);
}
 
Example 7
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    fieldrefConstant.u2classIndex =
        remapConstantIndex(fieldrefConstant.u2classIndex);
    fieldrefConstant.u2nameAndTypeIndex =
        remapConstantIndex(fieldrefConstant.u2nameAndTypeIndex);
}
 
Example 8
Source Project: java-n-IDE-for-Android   Source File: ConstantPoolEditor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Finds or creates a FieldrefConstant constant pool entry with the given
 * class constant pool entry index and name and type constant pool entry
 * index.
 * @return the constant pool index of the FieldrefConstant.
 */
public int addFieldrefConstant(int    classIndex,
                               int    nameAndTypeIndex,
                               Clazz  referencedClass,
                               Member referencedMember)
{
    int        constantPoolCount = targetClass.u2constantPoolCount;
    Constant[] constantPool      = targetClass.constantPool;

    // Check if the entry already exists.
    for (int index = 1; index < constantPoolCount; index++)
    {
        Constant constant = constantPool[index];

        if (constant != null &&
            constant.getTag() == ClassConstants.CONSTANT_Fieldref)
        {
            FieldrefConstant fieldrefConstant = (FieldrefConstant)constant;
            if (fieldrefConstant.u2classIndex         == classIndex &&
                fieldrefConstant.u2nameAndTypeIndex   == nameAndTypeIndex)
            {
                return index;
            }
        }
    }

    return addConstant(new FieldrefConstant(classIndex,
                                            nameAndTypeIndex,
                                            referencedClass,
                                            referencedMember));
}
 
Example 9
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    // Pass the referencing class.
    referencingClass = clazz;

    // We'll have to assume accessing an unknown field has side effects.
    hasSideEffects = true;

    // Check the referenced field, if known.
    fieldrefConstant.referencedMemberAccept(this);
}
 
Example 10
Source Project: atlas   Source File: ClassDetailVisitor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant) {

    //println("visitFieldrefConstant Methodref [" +
    //            clazz.getClassName(fieldrefConstant.u2classIndex) + "." +
    //            clazz.getName(fieldrefConstant.u2nameAndTypeIndex) + " " +
    //            clazz.getType(fieldrefConstant.u2nameAndTypeIndex) + "]");

    addField(clazz.getClassName(fieldrefConstant.u2classIndex),
             clazz.getName(fieldrefConstant.u2nameAndTypeIndex));

}
 
Example 11
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    // Is the constant retrieving from a wrapper class?
    fieldrefConstant.referencedClassAccept(this);
}
 
Example 12
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    String type = fieldrefConstant.getType(clazz);

    typeStackDelta = ClassUtil.internalTypeSize(ClassUtil.internalMethodReturnType(type));
}
 
Example 13
Source Project: java-n-IDE-for-Android   Source File: SimplifiedVisitor.java    License: Apache License 2.0 4 votes vote down vote up
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    visitAnyRefConstant(clazz, fieldrefConstant);
}
 
Example 14
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    // Mark the referenced field.
    fieldrefConstant.referencedMemberAccept(this);
}
 
Example 15
Source Project: atlas   Source File: AbstractClasslVisitor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant) {
}
 
Example 16
Source Project: java-n-IDE-for-Android   Source File: ConstantVisitor.java    License: Apache License 2.0 votes vote down vote up
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant);