/** * Constructs an immutable instance which is the combination of * the two given instances. The two instances must each have the * same number of elements, and each pair of elements must contain * disjoint sets of types. * * @param list1 {@code non-null;} an instance * @param list2 {@code non-null;} the other instance * @return {@code non-null;} the combination */ public static AnnotationsList combine(AnnotationsList list1, AnnotationsList list2) { int size = list1.size(); if (size != list2.size()) { throw new IllegalArgumentException("list1.size() != list2.size()"); } AnnotationsList result = new AnnotationsList(size); for (int i = 0; i < size; i++) { Annotations a1 = list1.get(i); Annotations a2 = list2.get(i); result.set(i, Annotations.combine(a1, a2)); } result.setImmutable(); return result; }
/** * Gets the element at the given index. It is an error to call * this with the index for an element which was never set; if you * do that, this will throw {@code NullPointerException}. * * @param n {@code >= 0, < size();} which index * @return {@code non-null;} element at that index */ public Annotations get(int n) { return (Annotations) get0(n); }
/** * Sets the element at the given index. The given element must be * immutable. * * @param n {@code >= 0, < size();} which index * @param a {@code null-ok;} the element to set at {@code n} */ public void set(int n, Annotations a) { a.throwIfMutable(); set0(n, a); } }
/** * Parses a list of annotation lists. * * @param visibility {@code non-null;} visibility of the parsed annotations * @return {@code non-null;} the list of annotation lists read from the attribute * data */ private AnnotationsList parseAnnotationsList( AnnotationVisibility visibility) throws IOException { int count = input.readUnsignedByte(); if (observer != null) { parsed(1, "num_parameters: " + Hex.u1(count)); } AnnotationsList outerList = new AnnotationsList(count); for (int i = 0; i < count; i++) { if (observer != null) { parsed(0, "parameter_annotations[" + i + "]:"); changeIndent(1); } Annotations annotations = parseAnnotations(visibility); outerList.set(i, annotations); if (observer != null) { observer.changeIndent(-1); } } outerList.setImmutable(); return outerList; }
if (list.size() != 0) { out.addParameterAnnotations(meth, list);
/** * Constructs an instance. * * @param attributeName {@code non-null;} the name of the attribute * @param parameterAnnotations {@code non-null;} the annotations * @param byteLength {@code >= 0;} attribute data length in the original * classfile (not including the attribute header) */ public BaseParameterAnnotations(String attributeName, AnnotationsList parameterAnnotations, int byteLength) { super(attributeName); try { if (parameterAnnotations.isMutable()) { throw new MutabilityException( "parameterAnnotations.isMutable()"); } } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("parameterAnnotations == null"); } this.parameterAnnotations = parameterAnnotations; this.byteLength = byteLength; }
return AnnotationsList.combine(visible.getParameterAnnotations(), invisible.getParameterAnnotations());
/** * Parses a list of annotation lists. * * @param visibility {@code non-null;} visibility of the parsed annotations * @return {@code non-null;} the list of annotation lists read from the attribute * data */ private AnnotationsList parseAnnotationsList( AnnotationVisibility visibility) throws IOException { int count = input.readUnsignedByte(); if (observer != null) { parsed(1, "num_parameters: " + Hex.u1(count)); } AnnotationsList outerList = new AnnotationsList(count); for (int i = 0; i < count; i++) { if (observer != null) { parsed(0, "parameter_annotations[" + i + "]:"); changeIndent(1); } Annotations annotations = parseAnnotations(visibility); outerList.set(i, annotations); if (observer != null) { observer.changeIndent(-1); } } outerList.setImmutable(); return outerList; }
if (list.size() != 0) { out.addParameterAnnotations(meth, list);
/** * Constructs an instance. * * @param attributeName {@code non-null;} the name of the attribute * @param parameterAnnotations {@code non-null;} the annotations * @param byteLength {@code >= 0;} attribute data length in the original * classfile (not including the attribute header) */ public BaseParameterAnnotations(String attributeName, AnnotationsList parameterAnnotations, int byteLength) { super(attributeName); try { if (parameterAnnotations.isMutable()) { throw new MutabilityException( "parameterAnnotations.isMutable()"); } } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("parameterAnnotations == null"); } this.parameterAnnotations = parameterAnnotations; this.byteLength = byteLength; }
return AnnotationsList.combine(visible.getParameterAnnotations(), invisible.getParameterAnnotations());
/** * Constructs an immutable instance which is the combination of * the two given instances. The two instances must each have the * same number of elements, and each pair of elements must contain * disjoint sets of types. * * @param list1 {@code non-null;} an instance * @param list2 {@code non-null;} the other instance * @return {@code non-null;} the combination */ public static AnnotationsList combine(AnnotationsList list1, AnnotationsList list2) { int size = list1.size(); if (size != list2.size()) { throw new IllegalArgumentException("list1.size() != list2.size()"); } AnnotationsList result = new AnnotationsList(size); for (int i = 0; i < size; i++) { Annotations a1 = list1.get(i); Annotations a2 = list2.get(i); result.set(i, Annotations.combine(a1, a2)); } result.setImmutable(); return result; }
/** * Parses a list of annotation lists. * * @param visibility {@code non-null;} visibility of the parsed annotations * @return {@code non-null;} the list of annotation lists read from the attribute * data */ private AnnotationsList parseAnnotationsList( AnnotationVisibility visibility) throws IOException { int count = input.readUnsignedByte(); if (observer != null) { parsed(1, "num_parameters: " + Hex.u1(count)); } AnnotationsList outerList = new AnnotationsList(count); for (int i = 0; i < count; i++) { if (observer != null) { parsed(0, "parameter_annotations[" + i + "]:"); changeIndent(1); } Annotations annotations = parseAnnotations(visibility); outerList.set(i, annotations); if (observer != null) { observer.changeIndent(-1); } } outerList.setImmutable(); return outerList; }
/** * Gets the element at the given index. It is an error to call * this with the index for an element which was never set; if you * do that, this will throw {@code NullPointerException}. * * @param n {@code >= 0, < size();} which index * @return {@code non-null;} element at that index */ public Annotations get(int n) { return (Annotations) get0(n); }
/** * Sets the element at the given index. The given element must be * immutable. * * @param n {@code >= 0, < size();} which index * @param a {@code null-ok;} the element to set at {@code n} */ public void set(int n, Annotations a) { a.throwIfMutable(); set0(n, a); } }
if (list.size() != 0) { out.addParameterAnnotations(meth, list, dexFile);
/** * Constructs an instance. * * @param attributeName {@code non-null;} the name of the attribute * @param parameterAnnotations {@code non-null;} the annotations * @param byteLength {@code >= 0;} attribute data length in the original * classfile (not including the attribute header) */ public BaseParameterAnnotations(String attributeName, AnnotationsList parameterAnnotations, int byteLength) { super(attributeName); try { if (parameterAnnotations.isMutable()) { throw new MutabilityException( "parameterAnnotations.isMutable()"); } } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("parameterAnnotations == null"); } this.parameterAnnotations = parameterAnnotations; this.byteLength = byteLength; }