private Set<Annotation> buildMethodAnnotations(SootMethod m) { Set<String> skipList = new HashSet<String>(); Set<Annotation> annotations = buildCommonAnnotations(m, skipList); for (Tag t : m.getTags()) { if (t.getName().equals("VisibilityAnnotationTag")) { List<ImmutableAnnotation> visibilityItems = buildVisibilityAnnotationTag((VisibilityAnnotationTag) t, skipList); annotations.addAll(visibilityItems); } } List<SootClass> exceptionList = m.getExceptionsUnsafe(); if (exceptionList != null && !exceptionList.isEmpty()) { List<ImmutableEncodedValue> valueList = new ArrayList<ImmutableEncodedValue>(exceptionList.size()); for (SootClass exceptionClass : exceptionList) { valueList.add(new ImmutableTypeEncodedValue(DexType.toDalvikICAT(exceptionClass.getName()).replace(".", "/"))); } ImmutableArrayEncodedValue valueValue = new ImmutableArrayEncodedValue(valueList); ImmutableAnnotationElement valueElement = new ImmutableAnnotationElement("value", valueValue); Set<ImmutableAnnotationElement> elements = Collections.singleton(valueElement); ImmutableAnnotation ann = new ImmutableAnnotation(AnnotationVisibility.SYSTEM, "Ldalvik/annotation/Throws;", elements); annotations.add(ann); } return annotations; }
ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableArrayEncodedValue); newAnnotationElement.add(immutableAnnotationElement); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableStringEncodedValue); newAnnotationElement.add(immutableAnnotationElement); ); ImmutableMethodEncodedValue immutableMethodEncodedValue = new ImmutableMethodEncodedValue(immutableReference); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableMethodEncodedValue); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableTypeEncodedValue); newAnnotationElement.add(immutableAnnotationElement); newAnnotationElement.add(ImmutableAnnotationElement.of(annotationElement));
public ImmutableAnnotationEncodedValue(@Nonnull String type, @Nullable Collection<? extends AnnotationElement> elements) { this.type = type; this.elements = ImmutableAnnotationElement.immutableSetOf(elements); }
@Nonnull @Override protected ImmutableAnnotationElement makeImmutable(@Nonnull AnnotationElement item) { return ImmutableAnnotationElement.of(item); } };
ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableArrayEncodedValue); newAnnotationElement.add(immutableAnnotationElement); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableStringEncodedValue); newAnnotationElement.add(immutableAnnotationElement); } else if (encodedValue instanceof TypeEncodedValue) { ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableTypeEncodedValue); ); ImmutableMethodEncodedValue immutableMethodEncodedValue = new ImmutableMethodEncodedValue(immutableReference); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableMethodEncodedValue); newAnnotationElement.add(ImmutableAnnotationElement.of(annotationElement));
public ImmutableAnnotationEncodedValue(@Nonnull String type, @Nullable Collection<? extends AnnotationElement> elements) { this.type = type; this.elements = ImmutableAnnotationElement.immutableSetOf(elements); }
@Nonnull @Override protected ImmutableAnnotationElement makeImmutable(@Nonnull AnnotationElement item) { return ImmutableAnnotationElement.of(item); } };
ImmutableAnnotationElement valueElement = new ImmutableAnnotationElement("value", valueValue); elements = Collections.singleton(valueElement); } else {
public ImmutableAnnotation(int visibility, @Nonnull String type, @Nullable Collection<? extends AnnotationElement> elements) { this.visibility = visibility; this.type = type; this.elements = ImmutableAnnotationElement.immutableSetOf(elements); }
@Nonnull @Override protected ImmutableAnnotationElement makeImmutable(@Nonnull AnnotationElement item) { return ImmutableAnnotationElement.of(item); } };
private Annotation buildEnclosingMethodTag(EnclosingMethodTag t, Set<String> skipList) { if (!skipList.add("Ldalvik/annotation/EnclosingMethod;")) { return null; } if (t.getEnclosingMethod() == null) { return null; } String[] split1 = t.getEnclosingMethodSig().split("\\)"); String parametersS = split1[0].replaceAll("\\(", ""); String returnTypeS = split1[1]; List<String> typeList = new ArrayList<String>(); if (!parametersS.equals("")) { for (String p : Util.splitParameters(parametersS)) { if (!p.isEmpty()) { typeList.add(p); } } } ImmutableMethodReference mRef = new ImmutableMethodReference(SootToDexUtils.getDexClassName(t.getEnclosingClass()), t.getEnclosingMethod(), typeList, returnTypeS); ImmutableMethodEncodedValue methodRef = new ImmutableMethodEncodedValue(mRef); AnnotationElement methodElement = new ImmutableAnnotationElement("value", methodRef); return new ImmutableAnnotation(AnnotationVisibility.SYSTEM, "Ldalvik/annotation/EnclosingMethod;", Collections.singleton(methodElement)); }
public ImmutableAnnotation(int visibility, @Nonnull String type, @Nullable Collection<? extends AnnotationElement> elements) { this.visibility = visibility; this.type = type; this.elements = ImmutableAnnotationElement.immutableSetOf(elements); }
ImmutableAnnotationElement element = new ImmutableAnnotationElement("value", classesValue); ImmutableAnnotation memberAnnotation = new ImmutableAnnotation(AnnotationVisibility.SYSTEM, "Ldalvik/annotation/MemberClasses;", Collections.singletonList(element));
public ImmutableAnnotationEncodedValue(@Nonnull String type, @Nullable Collection<? extends AnnotationElement> elements) { this.type = type; this.elements = ImmutableAnnotationElement.immutableSetOf(elements); }
ImmutableAnnotationElement element = new ImmutableAnnotationElement(ae.getName(), value); elements.add(element);
public ImmutableAnnotation(int visibility, @Nonnull String type, @Nullable Collection<? extends AnnotationElement> elements) { this.visibility = visibility; this.type = type; this.elements = ImmutableAnnotationElement.immutableSetOf(elements); }
= new ImmutableAnnotationElement("accessFlags", new ImmutableIntEncodedValue(icTag.getAccessFlags())); elements.add(flagsElement); ImmutableAnnotationElement nameElement = new ImmutableAnnotationElement("name", nameValue); elements.add(nameElement);
ImmutableAnnotationElement element = new ImmutableAnnotationElement(ae.getName(), value); elements.add(element);
if (skipList.add("Ldalvik/annotation/EnclosingClass;")) { ImmutableAnnotationElement enclosingElement = new ImmutableAnnotationElement("value", new ImmutableTypeEncodedValue(SootToDexUtils.getDexClassName(c.getOuterClass().getName()))); annotations.add(new ImmutableAnnotation(AnnotationVisibility.SYSTEM, "Ldalvik/annotation/EnclosingClass;",
public final AnnotationElement annotation_element() throws RecognitionException { AnnotationElement element = null; CommonTree SIMPLE_NAME237=null; ImmutableEncodedValue literal238 =null; try { // smaliTreeWalker.g:1398:3: ( ^( I_ANNOTATION_ELEMENT SIMPLE_NAME literal ) ) // smaliTreeWalker.g:1398:5: ^( I_ANNOTATION_ELEMENT SIMPLE_NAME literal ) { match(input,I_ANNOTATION_ELEMENT,FOLLOW_I_ANNOTATION_ELEMENT_in_annotation_element3922); match(input, Token.DOWN, null); SIMPLE_NAME237=(CommonTree)match(input,SIMPLE_NAME,FOLLOW_SIMPLE_NAME_in_annotation_element3924); pushFollow(FOLLOW_literal_in_annotation_element3926); literal238=literal(); state._fsp--; match(input, Token.UP, null); element = new ImmutableAnnotationElement((SIMPLE_NAME237!=null?SIMPLE_NAME237.getText():null), literal238); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return element; } // $ANTLR end "annotation_element"