/** * @ast method * @aspect AnnotationsCodegen * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/AnnotationsCodegen.jrag:305 */ public void appendAsAttributeTo(Collection list) { soot.tagkit.AnnotationTag tag = new soot.tagkit.AnnotationTag(decl().typeDescriptor(), getNumElementValuePair()); ArrayList elements = new ArrayList(getNumElementValuePair()); for(int i = 0; i < getNumElementValuePair(); i++) { String name = getElementValuePair(i).getName(); ElementValue value = getElementValuePair(i).getElementValue(); value.appendAsAttributeTo(elements, name); } tag.setElems(elements); list.add(tag); } /**
public String toString() { return super.toString() + "value: " + value.toString(); }
/** * Processes a normal annotation and adds it to the proper visibility annotation tag in the given array * * @param vatg * the visibility annotation tags for different visibility levels * @param a * the annotation * @param v * the visibility */ protected void addNormalAnnotation(VisibilityAnnotationTag[] vatg, Annotation a, int v) { if (vatg[v] == null) { vatg[v] = new VisibilityAnnotationTag(v); } AnnotationTag tag = new AnnotationTag(a.getType()); for (AnnotationElem e : getElements(a.getElements())) { tag.addElem(e); } vatg[v].addAnnotation(tag); }
private String getVisibilityAnnotationAttr(VisibilityAnnotationTag tag) { StringBuffer sb = new StringBuffer(); if (tag == null) { return ""; } else if (tag.getVisibility() == AnnotationConstants.RUNTIME_VISIBLE) { sb.append(".runtime_visible_annotation\n"); } else if (tag.getVisibility() == AnnotationConstants.RUNTIME_INVISIBLE) { sb.append(".runtime_invisible_annotation\n"); } else { // source level annotation return ""; } if (tag.hasAnnotations()) { Iterator<AnnotationTag> it = tag.getAnnotations().iterator(); while (it.hasNext()) { AnnotationTag annot = it.next(); sb.append(".annotation "); sb.append(soot.util.StringTools.getQuotedStringOf(annot.getType()) + "\n"); for (AnnotationElem ae : annot.getElems()) { sb.append(getElemAttr(ae)); } sb.append(".end .annotation\n"); } } sb.append(".end .annotation_attr\n"); return sb.toString(); }
@Override public void visitEnd() { AnnotationTag tag = new AnnotationTag(desc, elems); AnnotationElemBuilder.this.elems.add(new AnnotationAnnotationElem(tag, '@', name)); } };
@Override public void visitEnd() { AnnotationTag annotTag = new AnnotationTag(desc, elems); _vat.addAnnotation(annotTag); } };
String type = at.getType(); if (!skipList.add(type)) { continue; if (!at.getElems().isEmpty()) { elements = new ArrayList<AnnotationElement>(); for (AnnotationElem ae : at.getElems()) { if (ae.getName() == null || ae.getName().isEmpty()) { throw new RuntimeException("Null or empty annotation name encountered"); String typeName = SootToDexUtils.getDexClassName(at.getType()); ImmutableAnnotation ann = new ImmutableAnnotation(getVisibility(t.getVisibility()), typeName, elements); annotations.add(ann);
private void addAnnotations(int numAnnots, annotation [] annotations, ClassFile coffiClass, VisibilityAnnotationTag tag, List references){ for (int i = 0; i < numAnnots; i++){ annotation annot = annotations[i]; String annotType = ((CONSTANT_Utf8_info)coffiClass.constant_pool[annot.type_index]).convert(); String ref = annotType.substring(1, annotType.length()-1); ref = ref.replace('/', '.'); references.add(ref); int numElems = annot.num_element_value_pairs; AnnotationTag annotTag = new AnnotationTag(annotType, numElems); annotTag.setElems(createElementTags(numElems, coffiClass, annot.element_value_pairs)); tag.addAnnotation(annotTag); } }
AnnotationTag a = new AnnotationTag("Ldalvik/annotation/AnnotationDefault;"); defaultAnnotationTag.addAnnotation(a); AnnotationTag at = new AnnotationTag(SootToDexUtils.getDexClassName(c.getName())); AnnotationAnnotationElem ae = new AnnotationAnnotationElem(at, '@', "value"); a.addElem(ae); at.addElem(aelem);
@Override public void visitEnd() { AnnotationTag annotTag = new AnnotationTag(desc, elems); _tag.addAnnotation(annotTag); } };
public String toString() { StringBuffer sb = new StringBuffer("Visibility Annotation: level: "); switch (visibility) { case AnnotationConstants.RUNTIME_INVISIBLE: sb.append("CLASS (runtime-invisible)"); break; case AnnotationConstants.RUNTIME_VISIBLE: sb.append("RUNTIME (runtime-visible)"); break; case AnnotationConstants.SOURCE_VISIBLE: sb.append("SOURCE"); break; } sb.append("\n Annotations:"); if (annotations != null) { for (AnnotationTag tag : annotations) { sb.append("\n"); sb.append(tag.toString()); } } sb.append("\n"); return sb.toString(); }
final Class<?> clazz = ClassLoaderUtils.loadClass(tag.getType().replace('/', '.')); final Map<String, Object> map = new HashMap<String, Object>(); for (AnnotationElem elem : tag.getElems()) { AnnotationElemSwitch sw = new AnnotationElemSwitch(); elem.apply(sw); throw new RuntimeException("Could not load class: " + tag.getType());
private void addAnnotations(int numAnnots, annotation [] annotations, ClassFile coffiClass, VisibilityAnnotationTag tag, List references){ for (int i = 0; i < numAnnots; i++){ annotation annot = annotations[i]; String annotType = ((CONSTANT_Utf8_info)coffiClass.constant_pool[annot.type_index]).convert(); String ref = annotType.substring(1, annotType.length()-1); ref = ref.replace('/', '.'); references.add(ref); int numElems = annot.num_element_value_pairs; AnnotationTag annotTag = new AnnotationTag(annotType, numElems); annotTag.setElems(createElementTags(numElems, coffiClass, annot.element_value_pairs)); tag.addAnnotation(annotTag); } }
AnnotationTag adt = new AnnotationTag(a.getType()); adt.addElem(anne); if (vatg[v] == null) { vatg[v] = new VisibilityAnnotationTag(v); AnnotationTag deprecated = new AnnotationTag("Ljava/lang/Deprecated;"); if (vatg[v] == null) { vatg[v] = new VisibilityAnnotationTag(v);
private void addAnnotations(int numAnnots, annotation[] annotations, ClassFile coffiClass, VisibilityAnnotationTag tag, Collection<Type> references) { for (int i = 0; i < numAnnots; i++) { annotation annot = annotations[i]; String annotType = ((CONSTANT_Utf8_info) coffiClass.constant_pool[annot.type_index]).convert(); String ref = annotType.substring(1, annotType.length() - 1); ref = ref.replace('/', '.'); references.add(RefType.v(ref)); AnnotationTag annotTag = new AnnotationTag(annotType, createElementTags(annot.num_element_value_pairs, coffiClass, annot.element_value_pairs)); tag.addAnnotation(annotTag); } }
public String toString(){ return super.toString()+ "value: "+value.toString(); }
if (paramTagIdx == paramIdx && vat != null && vat.getAnnotations() != null) { for (AnnotationTag at : vat.getAnnotations()) { String type = at.getType(); if (!skipList.add(type)) { continue; if (!at.getElems().isEmpty()) { elements = new ArrayList<AnnotationElement>(); for (AnnotationElem ae : at.getElems()) { if (ae.getName() == null || ae.getName().isEmpty()) { throw new RuntimeException("Null or empty annotation name encountered"); SootToDexUtils.getDexClassName(at.getType()), elements); annotations.add(ann);
String annotType = ((CONSTANT_Utf8_info)coffiClass.constant_pool[annot.type_index]).convert(); int numElems = annot.num_element_value_pairs; AnnotationTag annotTag = new AnnotationTag(annotType, numElems); annotTag.setElems(createElementTags(numElems, coffiClass, annot.element_value_pairs));
AnnotationTag t = new AnnotationTag(DexType.toSootAT(v.getType()).toString()); for (AnnotationElement newElem : v.getElements()) { List<EncodedValue> l = new ArrayList<EncodedValue>(); if (aList != null) { for (AnnotationElem e : aList) { t.addElem(e);
/** * Applies a Java 1.5-style annotation to a given Host. The Host must be of type {@link SootClass}, {@link SootMethod} or * {@link SootField}. * * @param h * a method, field, or class * @param annotationName * the qualified name of the annotation class * @param visibility * any of the constants in {@link AnnotationConstants} * @param elems * a (possibly empty) sequence of AnnotationElem objects corresponding to the elements that should be contained in * this annotation */ public void annotate(Host h, String annotationName, int visibility, List<AnnotationElem> elems) { annotationName = annotationName.replace('.', '/'); if (!annotationName.endsWith(";")) { annotationName = "L" + annotationName + ';'; } VisibilityAnnotationTag tagToAdd = findOrAdd(h, visibility); AnnotationTag at = new AnnotationTag(annotationName, elems); tagToAdd.addAnnotation(at); }