Java Code Examples for proguard.classfile.attribute.annotation.Annotation#elementValuesAccept()

The following examples show how to use proguard.classfile.attribute.annotation.Annotation#elementValuesAccept() . 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: AnnotationUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    if (isReferencedClassUsed(annotation))
    {
        // Mark the annotation as being used.
        usageMarker.markAsUsed(annotation);

        markConstant(clazz, annotation.u2typeIndex);

        // Mark the necessary element values.
        annotation.elementValuesAccept(clazz, this);

        // The return values.
        annotationUsed = true;
        attributeUsed  = true;
    }
}
 
Example 2
Source File: AnnotationAdder.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitAnnotation(Clazz clazz, Method method, int parameterIndex, Annotation annotation)
{
    Annotation newAnnotation =
        new Annotation(constantAdder.addConstant(clazz, annotation.u2typeIndex),
                       0,
                       annotation.u2elementValuesCount > 0 ?
                           new ElementValue[annotation.u2elementValuesCount] :
                           EMPTY_ELEMENT_VALUES);

    // TODO: Clone array.
    newAnnotation.referencedClasses = annotation.referencedClasses;

    // Add the element values.
    annotation.elementValuesAccept(clazz,
                                   new ElementValueAdder(targetClass,
                                                         newAnnotation,
                                                         false));

    // Add the completed annotation.
    parameterAnnotationsAttributeEditor.addAnnotation(parameterIndex, newAnnotation);
}
 
Example 3
Source File: ClassReferenceFixer.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    // Compute the new type name.
    String typeName    = clazz.getString(annotation.u2typeIndex);
    String newTypeName = newDescriptor(typeName,
                                       annotation.referencedClasses);

    if (!typeName.equals(newTypeName))
    {
        // Refer to a new Utf8 entry.
        annotation.u2typeIndex =
            new ConstantPoolEditor((ProgramClass)clazz).addUtf8Constant(newTypeName);
    }

    // Fix the element values.
    annotation.elementValuesAccept(clazz, this);
}
 
Example 4
Source File: ClassShrinker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    // Shrink the element values array.
    annotation.u2elementValuesCount =
        shrinkArray(annotation.elementValues,
                    annotation.u2elementValuesCount);

    // Shrink the element values themselves.
    annotation.elementValuesAccept(clazz, this);
}
 
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 visitAnnotation(Clazz clazz, Annotation annotation)
{
    println(visitorInfo(annotation) +
            " Annotation [" + clazz.getString(annotation.u2typeIndex) + "]:");

    indent();
    annotation.elementValuesAccept(clazz, this);
    outdent();
}
 
Example 6
Source File: ReferencedClassVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    // Let the visitor visit the classes referenced in the annotation.
    annotation.referencedClassesAccept(classVisitor);

    // Visit the element values.
    annotation.elementValuesAccept(clazz, this);
}
 
Example 7
Source File: ClassReferenceInitializer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    annotation.referencedClasses =
        findReferencedClasses(clazz.getName(),
                              clazz.getString(annotation.u2typeIndex));

    // Initialize the element values.
    annotation.elementValuesAccept(clazz, this);
}
 
Example 8
Source File: ConstantPoolRemapper.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    annotation.u2typeIndex =
        remapConstantIndex(annotation.u2typeIndex);

    // Remap the constant pool references of the element values.
    annotation.elementValuesAccept(clazz, this);
}
 
Example 9
Source File: AnnotationAdder.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    Annotation newAnnotation =
        new Annotation(constantAdder.addConstant(clazz, annotation.u2typeIndex),
                       0,
                       annotation.u2elementValuesCount > 0 ?
                           new ElementValue[annotation.u2elementValuesCount] :
                           EMPTY_ELEMENT_VALUES);

    // TODO: Clone array.
    newAnnotation.referencedClasses = annotation.referencedClasses;

    // Add the element values.
    annotation.elementValuesAccept(clazz,
                                   new ElementValueAdder(targetClass,
                                                         newAnnotation,
                                                         false));

    // What's the target?
    if (targetAnnotationElementValue != null)
    {
        // Simply set the completed annotation.
        targetAnnotationElementValue.annotationValue = newAnnotation;
    }
    else
    {
        // Add the completed annotation.
        annotationsAttributeEditor.addAnnotation(newAnnotation);
    }
}
 
Example 10
Source File: ProgramClassWriter.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    // Write the annotation type.
    dataOutput.writeShort(annotation.u2typeIndex);

    // Write the element value pairs.
    dataOutput.writeShort(annotation.u2elementValuesCount);

    annotation.elementValuesAccept(clazz, this);
}
 
Example 11
Source File: TargetClassChanger.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    // Change the referenced classes.
    updateReferencedClasses(annotation.referencedClasses);

    // Change the references of the element values.
    annotation.elementValuesAccept(clazz, this);
}
 
Example 12
Source File: Utf8UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    markCpUtf8Entry(clazz, annotation.u2typeIndex);

    // Mark the UTF-8 entries referenced by the element values.
    annotation.elementValuesAccept(clazz, this);
}
 
Example 13
Source File: ClassCleaner.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    clean(annotation);

    annotation.elementValuesAccept(clazz, this);
}
 
Example 14
Source File: MemberReferenceFixer.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    // Fix the element values.
    annotation.elementValuesAccept(clazz, this);
}