@Test public void testCopyParameterAnnotationsMultipleSubsetWithShift() { SootClass sc = toSootClass(getClass()); SootMethod src = sc.getMethodByName("src7"); SootMethod dest = sc.getMethodByName("dest7"); copyParameterAnnotations(src, dest, 0, 3, 1, Visibility.Any); assertEquals("void dest7(int, @A @B @C int, @B @C @D int, @C @D @E int)", toString(dest)); }
private static void copyParameterAnnotations(SootMethod fromMethod, SootMethod toMethod, int start, int end, int shift, int visibility) { List<AnnotationTag>[] fromAnnos = getParameterAnnotations(fromMethod, Visibility.values()[visibility]); List<AnnotationTag>[] toAnnos = getParameterAnnotations(toMethod, Visibility.values()[visibility]); for (int i = start; i < end; i++) { toAnnos[i + shift].addAll(fromAnnos[i]); } for (Iterator<Tag> it = toMethod.getTags().iterator(); it.hasNext();) { Tag tag = it.next(); if (tag instanceof VisibilityParameterAnnotationTag) { if (((VisibilityParameterAnnotationTag) tag).getKind() == visibility) { it.remove(); } } } VisibilityParameterAnnotationTag vpaTag = new VisibilityParameterAnnotationTag(toAnnos.length, visibility); for (List<AnnotationTag> annos : toAnnos) { VisibilityAnnotationTag vaTag = new VisibilityAnnotationTag(visibility); for (AnnotationTag anno : annos) { vaTag.addAnnotation(anno); } vpaTag.addVisibilityAnnotation(vaTag); } toMethod.addTag(vpaTag); }
Annotations { private static void copyParameterAnnotations(SootMethod fromMethod, SootMethod toMethod, int start, int end, int shift, int visibility) { List<AnnotationTag>[] fromAnnos = getParameterAnnotations(fromMethod, Visibility.values()[visibility]); List<AnnotationTag>[] toAnnos = getParameterAnnotations(toMethod, Visibility.values()[visibility]); for (int i = start; i < end; i++) { toAnnos[i + shift].addAll(fromAnnos[i]); } for (Iterator<Tag> it = toMethod.getTags().iterator(); it.hasNext();) { Tag tag = it.next(); if (tag instanceof VisibilityParameterAnnotationTag) { if (((VisibilityParameterAnnotationTag) tag).getKind() == visibility) { it.remove(); } } } VisibilityParameterAnnotationTag vpaTag = new VisibilityParameterAnnotationTag(toAnnos.length, visibility); for (List<AnnotationTag> annos : toAnnos) { VisibilityAnnotationTag vaTag = new VisibilityAnnotationTag(visibility); for (AnnotationTag anno : annos) { vaTag.addAnnotation(anno); } vpaTag.addVisibilityAnnotation(vaTag); } toMethod.addTag(vpaTag); } }
Annotations { private static void copyParameterAnnotations(SootMethod fromMethod, SootMethod toMethod, int start, int end, int shift, int visibility) { List<AnnotationTag>[] fromAnnos = getParameterAnnotations(fromMethod, Visibility.values()[visibility]); List<AnnotationTag>[] toAnnos = getParameterAnnotations(toMethod, Visibility.values()[visibility]); for (int i = start; i < end; i++) { toAnnos[i + shift].addAll(fromAnnos[i]); } for (Iterator<Tag> it = toMethod.getTags().iterator(); it.hasNext();) { Tag tag = it.next(); if (tag instanceof VisibilityParameterAnnotationTag) { if (((VisibilityParameterAnnotationTag) tag).getKind() == visibility) { it.remove(); } } } VisibilityParameterAnnotationTag vpaTag = new VisibilityParameterAnnotationTag(toAnnos.length, visibility); for (List<AnnotationTag> annos : toAnnos) { VisibilityAnnotationTag vaTag = new VisibilityAnnotationTag(visibility); for (AnnotationTag anno : annos) { vaTag.addAnnotation(anno); } vpaTag.addVisibilityAnnotation(vaTag); } toMethod.addTag(vpaTag); }  }
Annotations { private static void copyParameterAnnotations(SootMethod fromMethod, SootMethod toMethod, int start, int end, int shift, int visibility) { List<AnnotationTag>[] fromAnnos = getParameterAnnotations(fromMethod, Visibility.values()[visibility]); List<AnnotationTag>[] toAnnos = getParameterAnnotations(toMethod, Visibility.values()[visibility]); for (int i = start; i < end; i++) { toAnnos[i + shift].addAll(fromAnnos[i]); } for (Iterator<Tag> it = toMethod.getTags().iterator(); it.hasNext();) { Tag tag = it.next(); if (tag instanceof VisibilityParameterAnnotationTag) { if (((VisibilityParameterAnnotationTag) tag).getKind() == visibility) { it.remove(); } } } VisibilityParameterAnnotationTag vpaTag = new VisibilityParameterAnnotationTag(toAnnos.length, visibility); for (List<AnnotationTag> annos : toAnnos) { VisibilityAnnotationTag vaTag = new VisibilityAnnotationTag(visibility); for (AnnotationTag anno : annos) { vaTag.addAnnotation(anno); } vpaTag.addVisibilityAnnotation(vaTag); } toMethod.addTag(vpaTag); }  static boolean hasAnnotation(Host host, String annotationType); static boolean hasParameterAnnotation(SootMethod method, int paramIndex, String annotationType); static List<AnnotationTag> getAnnotations(Host host, Visibility visibility); static AnnotationTag getAnnotation(Host host, String annotationType); static List<AnnotationTag> getParameterAnnotations(SootMethod method, int paramIndex, Visibility visibility); static List<AnnotationTag>[] getParameterAnnotations(SootMethod method, Visibility visibility); static AnnotationTag getParameterAnnotation(SootMethod method, int paramIndex, String annotationType); static boolean hasBridgeAnnotation(SootMethod method); static boolean hasCallbackAnnotation(SootMethod method); static boolean hasStructMemberAnnotation(SootMethod method); static boolean hasGlobalValueAnnotation(SootMethod method); static boolean hasArrayAnnotation(SootMethod method); static boolean hasArrayAnnotation(SootMethod method, int paramIndex); static boolean hasPointerAnnotation(SootMethod method); static boolean hasMachineSizedFloatAnnotation(SootMethod method); static boolean hasMachineSizedSIntAnnotation(SootMethod method); static boolean hasMachineSizedUIntAnnotation(SootMethod method); static boolean hasByValAnnotation(SootMethod method); static boolean hasByRefAnnotation(SootMethod method); static boolean hasStructRetAnnotation(SootMethod method, int paramIndex); static boolean hasPointerAnnotation(SootMethod method, int paramIndex); static boolean hasMachineSizedFloatAnnotation(SootMethod method, int paramIndex); static boolean hasMachineSizedSIntAnnotation(SootMethod method, int paramIndex); static boolean hasMachineSizedUIntAnnotation(SootMethod method, int paramIndex); static boolean hasByValAnnotation(SootMethod method, int paramIndex); static boolean hasByRefAnnotation(SootMethod method, int paramIndex); static boolean hasVariadicAnnotation(SootMethod method); static boolean hasWeaklyLinkedAnnotation(Host host); static boolean hasStronglyLinkedAnnotation(Host host); static int getVariadicParameterIndex(SootMethod method); static boolean hasAfterBridgeCallAnnotation(SootMethod method); static boolean hasAfterCallbackCallAnnotation(SootMethod method); static AnnotationTag getMarshalerAnnotation(SootMethod method, int paramIndex); static AnnotationTag getMarshalerAnnotation(SootMethod method); static List<AnnotationTag> getMarshalerAnnotations(SootClass clazz); static AnnotationTag getMarshalsPointerAnnotation(SootMethod method); static AnnotationTag getMarshalsValueAnnotation(SootMethod method); static AnnotationTag getMarshalsArrayAnnotation(SootMethod method); static AnnotationTag getStructMemberAnnotation(SootMethod method); static AnnotationTag getArrayAnnotation(SootMethod method); static AnnotationTag getArrayAnnotation(SootMethod method, int paramIndex); static AnnotationTag getBaseTypeAnnotation(SootMethod method); static boolean hasByValAnnotation(SootClass clazz); static boolean hasByRefAnnotation(SootClass clazz); static AnnotationElem getElemByName(AnnotationTag annotation, String name); static String readStringElem(AnnotationTag annotation, String name, String def); static boolean readBooleanElem(AnnotationTag annotation, String name, boolean def); static int readIntElem(AnnotationTag annotation, String name, int def); static VisibilityAnnotationTag getOrCreateRuntimeVisibilityAnnotationTag(Host host); static void addRuntimeVisibleAnnotation(Host host, String annotationType); static void addRuntimeVisibleAnnotation(Host host, AnnotationTag annoTag); static void removeAnnotation(Host host, String annotationType); static void removeParameterAnnotation(SootMethod method, int paramIndex, String annotationType); static void copyAnnotations(SootMethod fromMethod, SootMethod toMethod, Visibility visibility); static void copyParameterAnnotations(SootMethod fromMethod, SootMethod toMethod, int start, int end, int shift, Visibility visibility); static VisibilityAnnotationTag getOrCreateRuntimeVisibilityAnnotationTag(SootMethod method, int paramIndex); static void addRuntimeVisibleParameterAnnotation(SootMethod method, int paramIndex, String annotationType); static void addRuntimeVisibleParameterAnnotation(SootMethod method, int paramIndex, AnnotationTag annoTag); }
Annotations { private static void copyParameterAnnotations(SootMethod fromMethod, SootMethod toMethod, int start, int end, int shift, int visibility) { List<AnnotationTag>[] fromAnnos = getParameterAnnotations(fromMethod, Visibility.values()[visibility]); List<AnnotationTag>[] toAnnos = getParameterAnnotations(toMethod, Visibility.values()[visibility]); for (int i = start; i < end; i++) { toAnnos[i + shift].addAll(fromAnnos[i]); } for (Iterator<Tag> it = toMethod.getTags().iterator(); it.hasNext();) { Tag tag = it.next(); if (tag instanceof VisibilityParameterAnnotationTag) { if (((VisibilityParameterAnnotationTag) tag).getKind() == visibility) { it.remove(); } } } VisibilityParameterAnnotationTag vpaTag = new VisibilityParameterAnnotationTag(toAnnos.length, visibility); for (List<AnnotationTag> annos : toAnnos) { VisibilityAnnotationTag vaTag = new VisibilityAnnotationTag(visibility); for (AnnotationTag anno : annos) { vaTag.addAnnotation(anno); } vpaTag.addVisibilityAnnotation(vaTag); } toMethod.addTag(vpaTag); }  static boolean hasAnnotation(Host host, String annotationType); static boolean hasParameterAnnotation(SootMethod method, int paramIndex, String annotationType); static List<AnnotationTag> getAnnotations(Host host, Visibility visibility); static AnnotationTag getAnnotation(Host host, String annotationType); static List<AnnotationTag> getParameterAnnotations(SootMethod method, int paramIndex, Visibility visibility); static List<AnnotationTag>[] getParameterAnnotations(SootMethod method, Visibility visibility); static AnnotationTag getParameterAnnotation(SootMethod method, int paramIndex, String annotationType); static boolean hasBridgeAnnotation(SootMethod method); static boolean hasCallbackAnnotation(SootMethod method); static boolean hasStructMemberAnnotation(SootMethod method); static boolean hasGlobalValueAnnotation(SootMethod method); static boolean hasArrayAnnotation(SootMethod method); static boolean hasArrayAnnotation(SootMethod method, int paramIndex); static boolean hasPointerAnnotation(SootMethod method); static boolean hasMachineSizedFloatAnnotation(SootMethod method); static boolean hasMachineSizedSIntAnnotation(SootMethod method); static boolean hasMachineSizedUIntAnnotation(SootMethod method); static boolean hasByValAnnotation(SootMethod method); static boolean hasByRefAnnotation(SootMethod method); static boolean hasStructRetAnnotation(SootMethod method, int paramIndex); static boolean hasPointerAnnotation(SootMethod method, int paramIndex); static boolean hasMachineSizedFloatAnnotation(SootMethod method, int paramIndex); static boolean hasMachineSizedSIntAnnotation(SootMethod method, int paramIndex); static boolean hasMachineSizedUIntAnnotation(SootMethod method, int paramIndex); static boolean hasByValAnnotation(SootMethod method, int paramIndex); static boolean hasByRefAnnotation(SootMethod method, int paramIndex); static boolean hasVariadicAnnotation(SootMethod method); static boolean hasWeaklyLinkedAnnotation(Host host); static boolean hasStronglyLinkedAnnotation(Host host); static int getVariadicParameterIndex(SootMethod method); static boolean hasAfterBridgeCallAnnotation(SootMethod method); static boolean hasAfterCallbackCallAnnotation(SootMethod method); static AnnotationTag getMarshalerAnnotation(SootMethod method, int paramIndex); static AnnotationTag getMarshalerAnnotation(SootMethod method); static List<AnnotationTag> getMarshalerAnnotations(SootClass clazz); static AnnotationTag getMarshalsPointerAnnotation(SootMethod method); static AnnotationTag getMarshalsValueAnnotation(SootMethod method); static AnnotationTag getMarshalsArrayAnnotation(SootMethod method); static AnnotationTag getStructMemberAnnotation(SootMethod method); static AnnotationTag getArrayAnnotation(SootMethod method); static AnnotationTag getArrayAnnotation(SootMethod method, int paramIndex); static AnnotationTag getBaseTypeAnnotation(SootMethod method); static boolean hasByValAnnotation(SootClass clazz); static boolean hasByRefAnnotation(SootClass clazz); static AnnotationElem getElemByName(AnnotationTag annotation, String name); static String readStringElem(AnnotationTag annotation, String name, String def); static boolean readBooleanElem(AnnotationTag annotation, String name, boolean def); static int readIntElem(AnnotationTag annotation, String name, int def); static VisibilityAnnotationTag getOrCreateRuntimeVisibilityAnnotationTag(Host host); static void addRuntimeVisibleAnnotation(Host host, String annotationType); static void addRuntimeVisibleAnnotation(Host host, AnnotationTag annoTag); static void removeAnnotation(Host host, String annotationType); static void removeParameterAnnotation(SootMethod method, int paramIndex, String annotationType); static void copyAnnotations(SootMethod fromMethod, SootMethod toMethod, Visibility visibility); static void copyParameterAnnotations(SootMethod fromMethod, SootMethod toMethod, int start, int end, int shift, Visibility visibility); static VisibilityAnnotationTag getOrCreateRuntimeVisibilityAnnotationTag(SootMethod method, int paramIndex); static void addRuntimeVisibleParameterAnnotation(SootMethod method, int paramIndex, String annotationType); static void addRuntimeVisibleParameterAnnotation(SootMethod method, int paramIndex, AnnotationTag annoTag); static final String BRIDGE; static final String CALLBACK; static final String STRUCT_MEMBER; static final String GLOBAL_VALUE; static final String ARRAY; static final String BASE_TYPE; static final String STRUCT_RET; static final String POINTER; static final String MACHINE_SIZED_FLOAT; static final String MACHINE_SIZED_S_INT; static final String MACHINE_SIZED_U_INT; static final String MARSHALER; static final String MARSHALERS; static final String MARSHALS_POINTER; static final String MARSHALS_VALUE; static final String MARSHALS_ARRAY; static final String AFTER_BRIDGE_CALL; static final String AFTER_CALLBACK_CALL; static final String BY_VAL; static final String BY_REF; static final String VARIADIC; static final String WEAKLY_LINKED; static final String STRONGLY_LINKED; }