Java Code Examples for com.android.dx.rop.annotation.AnnotationsList#size()
The following examples show how to use
com.android.dx.rop.annotation.AnnotationsList#size() .
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: ParameterAnnotationStruct.java From Box with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param method {@code non-null;} the method in question * @param annotationsList {@code non-null;} the associated annotations list * @param dexFile {@code non-null;} dex output */ public ParameterAnnotationStruct(CstMethodRef method, AnnotationsList annotationsList, DexFile dexFile) { if (method == null) { throw new NullPointerException("method == null"); } if (annotationsList == null) { throw new NullPointerException("annotationsList == null"); } this.method = method; this.annotationsList = annotationsList; /* * Construct an item for the annotations list. TODO: This * requires way too much copying; fix it. */ int size = annotationsList.size(); ArrayList<AnnotationSetRefItem> arrayList = new ArrayList<AnnotationSetRefItem>(size); for (int i = 0; i < size; i++) { Annotations annotations = annotationsList.get(i); AnnotationSetItem item = new AnnotationSetItem(annotations, dexFile); arrayList.add(new AnnotationSetRefItem(item)); } this.annotationsItem = new UniformListItem<AnnotationSetRefItem>( ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList); }
Example 2
Source File: ParameterAnnotationStruct.java From Box with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param method {@code non-null;} the method in question * @param annotationsList {@code non-null;} the associated annotations list * @param dexFile {@code non-null;} dex output */ public ParameterAnnotationStruct(CstMethodRef method, AnnotationsList annotationsList, DexFile dexFile) { if (method == null) { throw new NullPointerException("method == null"); } if (annotationsList == null) { throw new NullPointerException("annotationsList == null"); } this.method = method; this.annotationsList = annotationsList; /* * Construct an item for the annotations list. TODO: This * requires way too much copying; fix it. */ int size = annotationsList.size(); ArrayList<AnnotationSetRefItem> arrayList = new ArrayList<AnnotationSetRefItem>(size); for (int i = 0; i < size; i++) { Annotations annotations = annotationsList.get(i); AnnotationSetItem item = new AnnotationSetItem(annotations, dexFile); arrayList.add(new AnnotationSetRefItem(item)); } this.annotationsItem = new UniformListItem<AnnotationSetRefItem>( ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList); }
Example 3
Source File: ParameterAnnotationStruct.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param method {@code non-null;} the method in question * @param annotationsList {@code non-null;} the associated annotations list * @param dexFile {@code non-null;} dex output */ public ParameterAnnotationStruct(CstMethodRef method, AnnotationsList annotationsList, DexFile dexFile) { if (method == null) { throw new NullPointerException("method == null"); } if (annotationsList == null) { throw new NullPointerException("annotationsList == null"); } this.method = method; this.annotationsList = annotationsList; /* * Construct an item for the annotations list. TODO: This * requires way too much copying; fix it. */ int size = annotationsList.size(); ArrayList<AnnotationSetRefItem> arrayList = new ArrayList<AnnotationSetRefItem>(size); for (int i = 0; i < size; i++) { Annotations annotations = annotationsList.get(i); AnnotationSetItem item = new AnnotationSetItem(annotations, dexFile); arrayList.add(new AnnotationSetRefItem(item)); } this.annotationsItem = new UniformListItem<AnnotationSetRefItem>( ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList); }
Example 4
Source File: ParameterAnnotationStruct.java From buck with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param method {@code non-null;} the method in question * @param annotationsList {@code non-null;} the associated annotations list * @param dexFile {@code non-null;} dex output */ public ParameterAnnotationStruct(CstMethodRef method, AnnotationsList annotationsList, DexFile dexFile) { if (method == null) { throw new NullPointerException("method == null"); } if (annotationsList == null) { throw new NullPointerException("annotationsList == null"); } this.method = method; this.annotationsList = annotationsList; /* * Construct an item for the annotations list. TODO: This * requires way too much copying; fix it. */ int size = annotationsList.size(); ArrayList<AnnotationSetRefItem> arrayList = new ArrayList<AnnotationSetRefItem>(size); for (int i = 0; i < size; i++) { Annotations annotations = annotationsList.get(i); AnnotationSetItem item = new AnnotationSetItem(annotations, dexFile); arrayList.add(new AnnotationSetRefItem(item)); } this.annotationsItem = new UniformListItem<AnnotationSetRefItem>( ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList); }
Example 5
Source File: AnnotationId.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static void addToParameters(DexMaker dexMaker, MethodId<?, ?> methodId, List<List<AnnotationId<?,?>>> annotationIds) { ClassDefItem classDefItem = dexMaker.getTypeDeclaration(methodId.declaringType).toClassDefItem(); if (classDefItem == null) { throw new NullPointerException("No class defined item is found"); } CstMethodRef cstMethodRef = methodId.constant; if (cstMethodRef == null) { throw new NullPointerException("Method reference is NULL"); } AnnotationsList list=new AnnotationsList(annotationIds.size()); for (int i=list.size()-1;i>=0;--i) { List<AnnotationId<?, ?>> ids = annotationIds.get(i); if(ids==null) continue; Annotations annotations = new Annotations(); for (AnnotationId<?,?> id:ids) { if (id.annotatedElement != ElementType.PARAMETER) { throw new IllegalStateException("This annotation is not for method"); } if (id.declaringType != methodId.declaringType) { throw new IllegalArgumentException("Method" + methodId + "'s declaring type is inconsistent with" + id); } // Generate CstType CstType cstType = CstType.intern(id.type.ropType); // Generate Annotation Annotation annotation = new Annotation(cstType, AnnotationVisibility.RUNTIME); // Add generated annotation for (NameValuePair nvp : id.elements.values()) { annotation.add(nvp); } annotations.add(annotation); } list.set(i,annotations); } classDefItem.addParameterAnnotations(cstMethodRef,list , dexMaker.getDexFile()); }