/** * This is used internally to construct a new <code>EncodedField</code> while reading in a * <code>DexFile</code> * * @param dexFile The <code>DexFile</code> that is being read in * @param in the Input object to read the <code>EncodedField</code> from * @param previousEncodedField The previous <code>EncodedField</code> in the list containing * this <code>EncodedField</code>. */ private EncodedField(DexFile dexFile, Input in, EncodedField previousEncodedField) { int previousIndex = previousEncodedField == null ? 0 : previousEncodedField.field.getIndex(); field = dexFile.FieldIdsSection.getItemByIndex(in.readUnsignedLeb128() + previousIndex); accessFlags = in.readUnsignedLeb128(); }
/** {@inheritDoc} */ protected void readItem(Input in, ReadContext readContext) { classAnnotations = (AnnotationSetItem) readContext.getOptionalOffsettedItemByOffset( ItemType.TYPE_ANNOTATION_SET_ITEM, in.readInt()); int fieldAnnotationCount = in.readInt(); if (fieldAnnotationCount > 0) { fieldAnnotations = new FieldAnnotation[fieldAnnotationCount]; } else { fieldAnnotations = null; } int methodAnnotationCount = in.readInt(); if (methodAnnotationCount > 0) { methodAnnotations = new MethodAnnotation[methodAnnotationCount]; } else { methodAnnotations = null; } int parameterAnnotationCount = in.readInt(); if (parameterAnnotationCount > 0) { parameterAnnotations = new ParameterAnnotation[parameterAnnotationCount]; } else { parameterAnnotations = null; } if (fieldAnnotations != null) { for (int i = 0; i < fieldAnnotations.length; i++) { try { FieldIdItem fieldIdItem = dexFile.FieldIdsSection.getItemByIndex(in.readInt()); AnnotationSetItem fieldAnnotationSet = (AnnotationSetItem) readContext.getOffsettedItemByOffset( ItemType.TYPE_ANNOTATION_SET_ITEM, in.readInt()); fieldAnnotations[i] = new FieldAnnotation(fieldIdItem, fieldAnnotationSet); } catch (Exception ex) { throw ExceptionWithContext.withContext( ex, "Error occured while reading FieldAnnotation at index " + i); } } } if (methodAnnotations != null) { for (int i = 0; i < methodAnnotations.length; i++) { try { MethodIdItem methodIdItem = dexFile.MethodIdsSection.getItemByIndex(in.readInt()); AnnotationSetItem methodAnnotationSet = (AnnotationSetItem) readContext.getOffsettedItemByOffset( ItemType.TYPE_ANNOTATION_SET_ITEM, in.readInt()); methodAnnotations[i] = new MethodAnnotation(methodIdItem, methodAnnotationSet); } catch (Exception ex) { throw ExceptionWithContext.withContext( ex, "Error occured while reading MethodAnnotation at index " + i); } } } if (parameterAnnotations != null) { for (int i = 0; i < parameterAnnotations.length; i++) { try { MethodIdItem methodIdItem = dexFile.MethodIdsSection.getItemByIndex(in.readInt()); AnnotationSetRefList paramaterAnnotationSet = (AnnotationSetRefList) readContext.getOffsettedItemByOffset( ItemType.TYPE_ANNOTATION_SET_REF_LIST, in.readInt()); parameterAnnotations[i] = new ParameterAnnotation(methodIdItem, paramaterAnnotationSet); } catch (Exception ex) { throw ExceptionWithContext.withContext( ex, "Error occured while reading ParameterAnnotation at index " + i); } } } }