Java Code Examples for org.jf.dexlib2.iface.Annotation#getElements()

The following examples show how to use org.jf.dexlib2.iface.Annotation#getElements() . 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: ImmutableAnnotation.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableAnnotation of(Annotation annotation) {
    if (annotation instanceof  ImmutableAnnotation) {
        return (ImmutableAnnotation)annotation;
    }
    return new ImmutableAnnotation(
            annotation.getVisibility(),
            annotation.getType(),
            annotation.getElements());
}
 
Example 2
Source File: AnnotationPool.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public void intern(@Nonnull Annotation annotation) {
    Integer prev = internedItems.put(annotation, 0);
    if (prev == null) {
        typePool.intern(annotation.getType());
        for (AnnotationElement element: annotation.getElements()) {
            stringPool.intern(element.getName());
            DexPool.internEncodedValue(element.getValue(), stringPool, typePool, fieldPool, methodPool);
        }
    }
}
 
Example 3
Source File: BackSmaliMain.java    From SimpleSmali with Apache License 2.0 5 votes vote down vote up
private static void annotionToString(Writer printStream, Annotation annotation, Indentation indent)
        throws IOException {
    List<String> attributes = new ArrayList<String>();
    Set<? extends AnnotationElement> elements = annotation.getElements();
    for (AnnotationElement element : elements) {
        attributes.add(String
                .format("%s=%s", element.getName(), DexEncodedValueUtils.getEncodeValue(element.getValue())));
    }
    printStream.write(indent.toString());
    printStream.write(String.format("@%s(%s)", annotation.getType(), String.join(",", attributes)));
    printStream.write(newLine);
}
 
Example 4
Source File: ApkPatch.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static void getMethodAnnotaionPrepareClasses(DexDiffInfo dexDiffInfo, Set<String> prepareclasses){

        for (DexBackedMethod method:dexDiffInfo.getModifiedMethods()){
            Set<? extends Annotation>annotations = method.getAnnotations();
            if (annotations == null){
                continue;
            }
            for (Annotation annotation:annotations){
                String type = annotation.getType();
                if (type!= null&&type.startsWith("L")&&type.endsWith(";")){
                    prepareclasses.add(type.substring(1, type.length() - 1).replace('/', '.'));
                    System.out.println("prepare class: " + type);
                }
                Set<? extends AnnotationElement> elements = annotation.getElements();
                for (AnnotationElement dexBackedAnnotationElement:elements){
                    if (dexBackedAnnotationElement.getValue() instanceof DexBackedArrayEncodedValue){
                        List<? extends EncodedValue> values = ((DexBackedArrayEncodedValue) dexBackedAnnotationElement.getValue()).getValue();
                        for (EncodedValue encodedValue:values) {
                            if (encodedValue instanceof TypeEncodedValue) {
                                prepareclasses.add(((TypeEncodedValue) encodedValue).getValue().substring(1, ((TypeEncodedValue) encodedValue).getValue().length() - 1).replace('/', '.'));
                                System.out.println("prepare class: " + ((TypeEncodedValue) encodedValue).getValue());
                            }
                        }

                    }else if (dexBackedAnnotationElement.getValue() instanceof DexBackedTypeEncodedValue){
                        String value = ((DexBackedTypeEncodedValue) dexBackedAnnotationElement.getValue()).getValue();
                        prepareclasses.add(value.substring(1, value.length() - 1).replace('/', '.'));
                        System.out.println("prepare class: " + value);
                    }
                }
            }
        }

    }
 
Example 5
Source File: ImmutableAnnotation.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableAnnotation of(Annotation annotation) {
    if (annotation instanceof  ImmutableAnnotation) {
        return (ImmutableAnnotation)annotation;
    }
    return new ImmutableAnnotation(
            annotation.getVisibility(),
            annotation.getType(),
            annotation.getElements());
}
 
Example 6
Source File: AnnotationPool.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public void intern(@Nonnull Annotation annotation) {
    Integer prev = internedItems.put(annotation, 0);
    if (prev == null) {
        typePool.intern(annotation.getType());
        for (AnnotationElement element: annotation.getElements()) {
            stringPool.intern(element.getName());
            DexPool.internEncodedValue(element.getValue(), stringPool, typePool, fieldPool, methodPool);
        }
    }
}
 
Example 7
Source File: ImmutableAnnotation.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public static ImmutableAnnotation of(Annotation annotation) {
    if (annotation instanceof  ImmutableAnnotation) {
        return (ImmutableAnnotation)annotation;
    }
    return new ImmutableAnnotation(
            annotation.getVisibility(),
            annotation.getType(),
            annotation.getElements());
}
 
Example 8
Source File: AnnotationPool.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public void intern(@Nonnull Annotation annotation) {
    Integer prev = internedItems.put(annotation, 0);
    if (prev == null) {
        typePool.intern(annotation.getType());
        for (AnnotationElement element: annotation.getElements()) {
            stringPool.intern(element.getName());
            DexPool.internEncodedValue(element.getValue(), stringPool, typePool, fieldPool, methodPool);
        }
    }
}
 
Example 9
Source File: ImmutableAnnotation.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static ImmutableAnnotation of(Annotation annotation) {
    if (annotation instanceof  ImmutableAnnotation) {
        return (ImmutableAnnotation)annotation;
    }
    return new ImmutableAnnotation(
            annotation.getVisibility(),
            annotation.getType(),
            annotation.getElements());
}
 
Example 10
Source File: AnnotationPool.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public void intern(@Nonnull Annotation annotation) {
    Integer prev = internedItems.put(annotation, 0);
    if (prev == null) {
        typePool.intern(annotation.getType());
        for (AnnotationElement element: annotation.getElements()) {
            stringPool.intern(element.getName());
            DexPool.internEncodedValue(element.getValue(), stringPool, typePool, fieldPool, methodPool);
        }
    }
}
 
Example 11
Source File: AnnotationPool.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nonnull @Override public Collection<? extends AnnotationElement> getElements(@Nonnull Annotation annotation) {
    return annotation.getElements();
}
 
Example 12
Source File: AnnotationPool.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Nonnull @Override public Collection<? extends AnnotationElement> getElements(@Nonnull Annotation annotation) {
    return annotation.getElements();
}
 
Example 13
Source File: AnnotationPool.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Nonnull @Override public Collection<? extends AnnotationElement> getElements(@Nonnull Annotation annotation) {
    return annotation.getElements();
}
 
Example 14
Source File: AnnotationPool.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nonnull @Override public Collection<? extends AnnotationElement> getElements(@Nonnull Annotation annotation) {
    return annotation.getElements();
}