/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // Sort the array to be in type id index order. AnnotationItem.sortByTypeIdIndex(items); }
/** * Constructs an instance. * * @param annotation {@code non-null;} annotation to represent * @param dexFile {@code non-null;} dex output */ public AnnotationItem(Annotation annotation, DexFile dexFile) { /* * The write size isn't known up-front because (the variable-lengthed) * leb128 type is used to represent some things. */ super(ALIGNMENT, -1); if (annotation == null) { throw new NullPointerException("annotation == null"); } this.annotation = annotation; this.type = null; this.encodedForm = null; addContents(dexFile); }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { boolean annotates = out.annotates(); int size = items.length; if (annotates) { out.annotate(0, offsetString() + " annotation set"); out.annotate(4, " size: " + Hex.u4(size)); } out.writeInt(size); for (int i = 0; i < size; i++) { AnnotationItem item = items[i]; int offset = item.getAbsoluteOffset(); if (annotates) { out.annotate(4, " entries[" + Integer.toHexString(i) + "]: " + Hex.u4(offset)); items[i].annotateTo(out, " "); } out.writeInt(offset); } } }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // Encode the data and note the size. ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(); ValueEncoder encoder = new ValueEncoder(addedTo.getFile(), out); encoder.writeAnnotation(annotation, false); encodedForm = out.toByteArray(); // Add one for the visibility byte in front of the encoded annotation. setWriteSize(encodedForm.length + 1); }
/** * Constructs an instance. * * @param annotations {@code non-null;} set of annotations */ public AnnotationSetItem(Annotations annotations) { super(ALIGNMENT, writeSize(annotations)); this.annotations = annotations; this.items = new AnnotationItem[annotations.size()]; int at = 0; for (Annotation a : annotations.getAnnotations()) { items[at] = new AnnotationItem(a); at++; } }
out.annotate(0, offsetString() + " annotation"); out.annotate(1, " visibility: VISBILITY_" + visibility);
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { boolean annotates = out.annotates(); int size = items.length; if (annotates) { out.annotate(0, offsetString() + " annotation set"); out.annotate(4, " size: " + Hex.u4(size)); } out.writeInt(size); for (int i = 0; i < size; i++) { AnnotationItem item = items[i]; int offset = item.getAbsoluteOffset(); if (annotates) { out.annotate(4, " entries[" + Integer.toHexString(i) + "]: " + Hex.u4(offset)); items[i].annotateTo(out, " "); } out.writeInt(offset); } } }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // Encode the data and note the size. ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(); ValueEncoder encoder = new ValueEncoder(addedTo.getFile(), out); encoder.writeAnnotation(annotation, false); encodedForm = out.toByteArray(); // Add one for the visibility byte in front of the encoded annotation. setWriteSize(encodedForm.length + 1); }
/** * Constructs an instance. * * @param annotations {@code non-null;} set of annotations * @param dexFile {@code non-null;} dex output */ public AnnotationSetItem(Annotations annotations, DexFile dexFile) { super(ALIGNMENT, writeSize(annotations)); this.annotations = annotations; this.items = new AnnotationItem[annotations.size()]; int at = 0; for (Annotation a : annotations.getAnnotations()) { items[at] = new AnnotationItem(a, dexFile); at++; } }
out.annotate(0, offsetString() + " annotation"); out.annotate(1, " visibility: VISBILITY_" + visibility);
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { boolean annotates = out.annotates(); int size = items.length; if (annotates) { out.annotate(0, offsetString() + " annotation set"); out.annotate(4, " size: " + Hex.u4(size)); } out.writeInt(size); for (int i = 0; i < size; i++) { AnnotationItem item = items[i]; int offset = item.getAbsoluteOffset(); if (annotates) { out.annotate(4, " entries[" + Integer.toHexString(i) + "]: " + Hex.u4(offset)); items[i].annotateTo(out, " "); } out.writeInt(offset); } } }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // Encode the data and note the size. ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(); ValueEncoder encoder = new ValueEncoder(addedTo.getFile(), out); encoder.writeAnnotation(annotation, false); encodedForm = out.toByteArray(); // Add one for the visibility byte in front of the encoded annotation. setWriteSize(encodedForm.length + 1); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // Sort the array to be in type id index order. AnnotationItem.sortByTypeIdIndex(items); }
/** * Constructs an instance. * * @param annotations {@code non-null;} set of annotations * @param dexFile {@code non-null;} dex output */ public AnnotationSetItem(Annotations annotations, DexFile dexFile) { super(ALIGNMENT, writeSize(annotations)); this.annotations = annotations; this.items = new AnnotationItem[annotations.size()]; int at = 0; for (Annotation a : annotations.getAnnotations()) { items[at] = new AnnotationItem(a, dexFile); at++; } }
out.annotate(0, offsetString() + " annotation"); out.annotate(1, " visibility: VISBILITY_" + visibility);
/** * Constructs an instance. * * @param annotation {@code non-null;} annotation to represent * @param dexFile {@code non-null;} dex output */ public AnnotationItem(Annotation annotation, DexFile dexFile) { /* * The write size isn't known up-front because (the variable-lengthed) * leb128 type is used to represent some things. */ super(ALIGNMENT, -1); if (annotation == null) { throw new NullPointerException("annotation == null"); } this.annotation = annotation; this.type = null; this.encodedForm = null; addContents(dexFile); }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { boolean annotates = out.annotates(); int size = items.length; if (annotates) { out.annotate(0, offsetString() + " annotation set"); out.annotate(4, " size: " + Hex.u4(size)); } out.writeInt(size); for (int i = 0; i < size; i++) { AnnotationItem item = items[i]; int offset = item.getAbsoluteOffset(); if (annotates) { out.annotate(4, " entries[" + Integer.toHexString(i) + "]: " + Hex.u4(offset)); items[i].annotateTo(out, " "); } out.writeInt(offset); } } }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // Encode the data and note the size. ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(); ValueEncoder encoder = new ValueEncoder(addedTo.getFile(), out); encoder.writeAnnotation(annotation, false); encodedForm = out.toByteArray(); // Add one for the visibility byte in front of the encoded annotation. setWriteSize(encodedForm.length + 1); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // Sort the array to be in type id index order. AnnotationItem.sortByTypeIdIndex(items); }
/** * Constructs an instance. * * @param annotations {@code non-null;} set of annotations */ public AnnotationSetItem(Annotations annotations) { super(ALIGNMENT, writeSize(annotations)); this.annotations = annotations; this.items = new AnnotationItem[annotations.size()]; int at = 0; for (Annotation a : annotations.getAnnotations()) { items[at] = new AnnotationItem(a); at++; } }