proguard.classfile.constant.RefConstant Java Examples

The following examples show how to use proguard.classfile.constant.RefConstant. 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 visitAnyMethodrefConstant(Clazz clazz, RefConstant methodrefConstant)
{
    String type = methodrefConstant.getType(clazz);

    // Count the number of parameters.
    int parameterCount = ClassUtil.internalMethodParameterCount(type);
    if (!isStatic)
    {
        parameterCount++;
    }

    // Pop the parameters and the class reference, in reverse order.
    for (int parameterIndex = parameterCount-1; parameterIndex >= 0; parameterIndex--)
    {
        setMethodParameterValue(clazz, methodrefConstant, parameterIndex, stack.pop());
    }

    // Push the return value, if applicable.
    String returnType = ClassUtil.internalMethodReturnType(type);
    if (returnType.charAt(0) != ClassConstants.INTERNAL_TYPE_VOID)
    {
        stack.push(getMethodReturnValue(clazz, methodrefConstant, returnType));
    }
}
 
Example #2
Source File: StoringInvocationUnit.java    From bazel with Apache License 2.0 6 votes vote down vote up
protected void setMethodParameterValue(Clazz       clazz,
                                       RefConstant refConstant,
                                       int         parameterIndex,
                                       Value       value)
{
    if (storeMethodParameterValues)
    {
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            generalizeMethodParameterValue((Method)referencedMember,
                                           parameterIndex,
                                           value);
        }
    }
}
 
Example #3
Source File: LoadingInvocationUnit.java    From bazel with Apache License 2.0 6 votes vote down vote up
protected Value getMethodReturnValue(Clazz       clazz,
                                     RefConstant refConstant,
                                     String      type)
{
    if (loadMethodReturnValues)
    {
        // Do we know this method?
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            // Retrieve the stored method return value.
            Value value = StoringInvocationUnit.getMethodReturnValue((Method)referencedMember);
            if (value != null)
            {
                return value;
            }
        }
    }

    return super.getMethodReturnValue(clazz,
                                      refConstant,
                                      type);
}
 
Example #4
Source File: LoadingInvocationUnit.java    From bazel with Apache License 2.0 6 votes vote down vote up
protected Value getFieldValue(Clazz       clazz,
                              RefConstant refConstant,
                              String      type)
{
    if (loadFieldValues)
    {
        // Do we know this field?
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            // Retrieve the stored field value.
            Value value = StoringInvocationUnit.getFieldValue((Field)referencedMember);
            if (value != null)
            {
                return value;
            }
        }
    }

    return super.getFieldValue(clazz, refConstant, type);
}
 
Example #5
Source File: LoadingInvocationUnit.java    From bazel with Apache License 2.0 6 votes vote down vote up
protected Value getFieldClassValue(Clazz       clazz,
                                   RefConstant refConstant,
                                   String      type)
{
    if (loadFieldValues)
    {
        // Do we know this field?
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            // Retrieve the stored field class value.
            ReferenceValue value = StoringInvocationUnit.getFieldClassValue((Field)referencedMember);
            if (value != null)
            {
                return value;
            }
        }
    }

    return super.getFieldClassValue(clazz, refConstant, type);
}
 
Example #6
Source File: StoringInvocationUnit.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
protected void setMethodParameterValue(Clazz       clazz,
                                       RefConstant refConstant,
                                       int         parameterIndex,
                                       Value       value)
{
    if (storeMethodParameterValues)
    {
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            generalizeMethodParameterValue((Method)referencedMember,
                                           parameterIndex,
                                           value);
        }
    }
}
 
Example #7
Source File: LoadingInvocationUnit.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
protected Value getMethodReturnValue(Clazz       clazz,
                                     RefConstant refConstant,
                                     String      type)
{
    if (loadMethodReturnValues)
    {
        // Do we know this method?
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            // Retrieve the stored method return value.
            Value value = StoringInvocationUnit.getMethodReturnValue((Method)referencedMember);
            if (value != null)
            {
                return value;
            }
        }
    }

    return super.getMethodReturnValue(clazz,
                                      refConstant,
                                      type);
}
 
Example #8
Source File: LoadingInvocationUnit.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
protected Value getFieldValue(Clazz       clazz,
                              RefConstant refConstant,
                              String      type)
{
    if (loadFieldValues)
    {
        // Do we know this field?
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            // Retrieve the stored field value.
            Value value = StoringInvocationUnit.getFieldValue((Field)referencedMember);
            if (value != null)
            {
                return value;
            }
        }
    }

    return super.getFieldValue(clazz, refConstant, type);
}
 
Example #9
Source File: LoadingInvocationUnit.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
protected Value getFieldClassValue(Clazz       clazz,
                                   RefConstant refConstant,
                                   String      type)
{
    if (loadFieldValues)
    {
        // Do we know this field?
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            // Retrieve the stored field class value.
            ReferenceValue value = StoringInvocationUnit.getFieldClassValue((Field)referencedMember);
            if (value != null)
            {
                return value;
            }
        }
    }

    return super.getFieldClassValue(clazz, refConstant, type);
}
 
Example #10
Source File: StoringInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
protected void setMethodParameterValue(Clazz       clazz,
                                       RefConstant refConstant,
                                       int         parameterIndex,
                                       Value value)
{
    if (storeMethodParameterValues)
    {
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            generalizeMethodParameterValue((Method)referencedMember,
                                           parameterIndex,
                                           value);
        }
    }
}
 
Example #11
Source File: LoadingInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
protected Value getMethodReturnValue(Clazz       clazz,
                                     RefConstant refConstant,
                                     String      type)
{
    if (loadMethodReturnValues)
    {
        // Do we know this method?
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            // Retrieve the stored method return value.
            Value value = StoringInvocationUnit.getMethodReturnValue((Method)referencedMember);
            if (value != null &&
                value.isParticular())
            {
                return value;
            }
        }
    }

    return super.getMethodReturnValue(clazz,
                                      refConstant,
                                      type);
}
 
Example #12
Source File: LoadingInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
protected Value getFieldValue(Clazz       clazz,
                              RefConstant refConstant,
                              String      type)
{
    if (loadFieldValues)
    {
        // Do we know this field?
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            // Retrieve the stored field value.
            Value value = StoringInvocationUnit.getFieldValue((Field)referencedMember);
            if (value != null &&
                value.isParticular())
            {
                return value;
            }
        }
    }

    return super.getFieldValue(clazz, refConstant, type);
}
 
Example #13
Source File: LoadingInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
protected Value getFieldClassValue(Clazz       clazz,
                                   RefConstant refConstant,
                                   String      type)
{
    if (loadFieldValues)
    {
        // Do we know this field?
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            // Retrieve the stored field class value.
            ReferenceValue value = StoringInvocationUnit.getFieldClassValue((Field)referencedMember);
            if (value != null &&
                value.isParticular())
            {
                return value;
            }
        }
    }

    return super.getFieldClassValue(clazz, refConstant, type);
}
 
Example #14
Source File: MethodInvocationFixer.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitAnyMethodrefConstant(Clazz clazz, RefConstant refConstant)
{
    // Remember the referenced class. Note that we're interested in the
    // class of the method reference, not in the class in which the
    // method was actually found, unless it is an array type.
    //
    if (ClassUtil.isInternalArrayType(refConstant.getClassName(clazz)))
    {
        // For an array type, the class will be java.lang.Object.
        referencedClass = refConstant.referencedClass;
    }
    else
    {
        clazz.constantPoolEntryAccept(refConstant.u2classIndex, this);
    }

    // Remember the referenced method.
    referencedMethodClass = refConstant.referencedClass;
    referencedMethod      = refConstant.referencedMember;
}
 
Example #15
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant)
{
    if (shouldBeMarkedAsUsed(refConstant))
    {
        markAsUsed(refConstant);

        markConstant(clazz, refConstant.u2classIndex);
        markConstant(clazz, refConstant.u2nameAndTypeIndex);

        // When compiled with "-target 1.2" or higher, the class or
        // interface actually containing the referenced class member may
        // be higher up the hierarchy. Make sure it's marked, in case it
        // isn't used elsewhere.
        refConstant.referencedClassAccept(this);

        // Mark the referenced class member itself.
        refConstant.referencedMemberAccept(this);
    }
}
 
Example #16
Source File: StringSharer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant)
{
    Member referencedMember = refConstant.referencedMember;
    if (referencedMember != null)
    {
        Clazz referencedClass = refConstant.referencedClass;

        // Put the actual class member's name and type strings in the class
        // pool.
        name = referencedMember.getName(referencedClass);
        type = referencedMember.getDescriptor(referencedClass);
        clazz.constantPoolEntryAccept(refConstant.u2nameAndTypeIndex, this);
    }
}
 
Example #17
Source File: StoringInvocationUnit.java    From bazel with Apache License 2.0 5 votes vote down vote up
protected void setFieldValue(Clazz       clazz,
                             RefConstant refConstant,
                             Value       value)
{
    if (storeFieldValues)
    {
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            generalizeFieldValue((Field)referencedMember, value);
        }
    }
}
 
Example #18
Source File: StoringInvocationUnit.java    From bazel with Apache License 2.0 5 votes vote down vote up
protected void setFieldClassValue(Clazz          clazz,
                                  RefConstant    refConstant,
                                  ReferenceValue value)
{
    if (storeFieldValues)
    {
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            generalizeFieldClassValue((Field)referencedMember, value);
        }
    }
}
 
Example #19
Source File: BasicInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the class through which the specified field is accessed.
 */
protected void setFieldClassValue(Clazz          clazz,
                                  RefConstant refConstant,
                                  ReferenceValue value)
{
    // We don't care about the new value.
}
 
Example #20
Source File: BasicInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the class though which the specified field is accessed.
 */
protected Value getFieldClassValue(Clazz       clazz,
                                   RefConstant refConstant,
                                   String      type)
{
    // Try to figure out the class of the return type.
    returnTypeClass = null;
    refConstant.referencedMemberAccept(this);

    return valueFactory.createValue(type,
                                    returnTypeClass,
                                    true);
}
 
Example #21
Source File: BasicInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the value of the specified field.
 */
protected void setFieldValue(Clazz       clazz,
                             RefConstant refConstant,
                             Value value)
{
    // We don't care about the new field value.
}
 
Example #22
Source File: BasicInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of the specified field.
 */
protected Value getFieldValue(Clazz       clazz,
                              RefConstant refConstant,
                              String      type)
{
    // Try to figure out the class of the return type.
    returnTypeClass = null;
    refConstant.referencedMemberAccept(this);

    return valueFactory.createValue(type,
                                    returnTypeClass,
                                    true);
}
 
Example #23
Source File: StoringInvocationUnit.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
protected void setFieldValue(Clazz       clazz,
                             RefConstant refConstant,
                             Value       value)
{
    if (storeFieldValues)
    {
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            generalizeFieldValue((Field)referencedMember, value);
        }
    }
}
 
Example #24
Source File: StoringInvocationUnit.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
protected void setFieldClassValue(Clazz          clazz,
                                  RefConstant    refConstant,
                                  ReferenceValue value)
{
    if (storeFieldValues)
    {
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            generalizeFieldClassValue((Field)referencedMember, value);
        }
    }
}
 
Example #25
Source File: BasicInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the value of the specified method parameter.
 */
protected void setMethodParameterValue(Clazz       clazz,
                                       RefConstant refConstant,
                                       int         parameterIndex,
                                       Value value)
{
    // We don't care about the parameter value.
}
 
Example #26
Source File: BasicInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the return value of the specified method.
 */
protected Value getMethodReturnValue(Clazz       clazz,
                                     RefConstant refConstant,
                                     String      type)
{
    // Try to figure out the class of the return type.
    returnTypeClass = null;
    refConstant.referencedMemberAccept(this);

    return valueFactory.createValue(type,
                                    returnTypeClass,
                                    true);
}
 
Example #27
Source File: TargetClassChanger.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant)
{
    Clazz referencedClass    = refConstant.referencedClass;
    Clazz newReferencedClass = updateReferencedClass(referencedClass);
    if (referencedClass != newReferencedClass)
    {
        if (DEBUG)
        {
            System.out.println("TargetClassChanger:");
            System.out.println("  ["+clazz.getName()+"] changing reference from ["+refConstant.referencedClass+"."+refConstant.referencedMember.getName(refConstant.referencedClass)+refConstant.referencedMember.getDescriptor(refConstant.referencedClass)+"]");
        }

        // Change the referenced class.
        refConstant.referencedClass  = newReferencedClass;

        // Change the referenced class member.
        refConstant.referencedMember =
            updateReferencedMember(refConstant.referencedMember,
                                   refConstant.getName(clazz),
                                   refConstant.getType(clazz),
                                   newReferencedClass);

        if (DEBUG)
        {
            System.out.println("  ["+clazz.getName()+"]                    to   ["+refConstant.referencedClass+"."+refConstant.referencedMember.getName(refConstant.referencedClass)+refConstant.referencedMember.getDescriptor(refConstant.referencedClass)+"]");
        }
    }
}
 
Example #28
Source File: ConstantInstruction.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void visitRefConstant(Clazz clazz, RefConstant methodrefConstant)
{
    String type = methodrefConstant.getType(clazz);

    parameterStackDelta = ClassUtil.internalMethodParameterSize(type);
    typeStackDelta      = ClassUtil.internalTypeSize(ClassUtil.internalMethodReturnType(type));
}
 
Example #29
Source File: StoringInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
protected void setFieldValue(Clazz       clazz,
                             RefConstant refConstant,
                             Value value)
{
    if (storeFieldValues)
    {
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            generalizeFieldValue((Field)referencedMember, value);
        }
    }
}
 
Example #30
Source File: StoringInvocationUnit.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
protected void setFieldClassValue(Clazz          clazz,
                                  RefConstant refConstant,
                                  ReferenceValue value)
{
    if (storeFieldValues)
    {
        Member referencedMember = refConstant.referencedMember;
        if (referencedMember != null)
        {
            generalizeFieldClassValue((Field)referencedMember, value);
        }
    }
}