proguard.classfile.constant.FieldrefConstant Java Examples

The following examples show how to use proguard.classfile.constant.FieldrefConstant. 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: BasicInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
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
Source File: MemberReferenceFixer.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
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 File: LibraryClassReader.java    From java-n-IDE-for-Android with 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 File: ProgramClassReader.java    From java-n-IDE-for-Android with 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 File: ClassPrinter.java    From java-n-IDE-for-Android with 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 File: ConstantAdder.java    From java-n-IDE-for-Android with 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
Source File: ConstantPoolRemapper.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    fieldrefConstant.u2classIndex =
        remapConstantIndex(fieldrefConstant.u2classIndex);
    fieldrefConstant.u2nameAndTypeIndex =
        remapConstantIndex(fieldrefConstant.u2nameAndTypeIndex);
}
 
Example #8
Source File: ConstantPoolEditor.java    From java-n-IDE-for-Android with 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
Source File: SideEffectInstructionChecker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
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 File: ClassDetailVisitor.java    From atlas with 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
Source File: WrapperClassUseSimplifier.java    From proguard with GNU General Public License v2.0 4 votes vote down vote up
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    // Is the constant retrieving from a wrapper class?
    fieldrefConstant.referencedClassAccept(this);
}
 
Example #12
Source File: ConstantInstruction.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
    String type = fieldrefConstant.getType(clazz);

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