private void updateField(FieldInfo fieldInfo) { // generic signature updateChars(fieldInfo.getGenericSignature()); updateInt(fieldInfo.getModifiers()); updateLong(fieldInfo.getTagBits() & TagBits.AnnotationDeprecated); updateAnnotations(fieldInfo.getAnnotations()); updateTypeAnnotations(fieldInfo.getTypeAnnotations()); updateChars(fieldInfo.getName()); updateChars(fieldInfo.getTypeName()); updateBoolean(fieldInfo.hasConstant()); if (fieldInfo.hasConstant()) { updateConstant(fieldInfo.getConstant()); } }
public static FieldInfo createField(byte classFileBytes[], int offsets[], int offset) { FieldInfo fieldInfo = new FieldInfo(classFileBytes, offsets, offset); AnnotationInfo[] annotations = fieldInfo.readAttributes(); if (annotations == null) return fieldInfo; return new FieldInfoWithAnnotation(fieldInfo, annotations); }
/** * This method is used to fully initialize the contents of the receiver. All methodinfos, fields infos * will be therefore fully initialized and we can get rid of the bytes. */ protected void initialize() { getModifiers(); getName(); getConstant(); getTypeName(); getGenericSignature(); reset(); } /**
protected void toStringContent(StringBuffer buffer) { int modifiers = getModifiers(); buffer .append('{') .append( ((modifiers & ClassFileConstants.AccDeprecated) != 0 ? "deprecated " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0001) == 1 ? "public " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0002) == 0x0002 ? "private " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0004) == 0x0004 ? "protected " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0008) == 0x000008 ? "static " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0010) == 0x0010 ? "final " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0040) == 0x0040 ? "volatile " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0080) == 0x0080 ? "transient " : Util.EMPTY_STRING)) //$NON-NLS-1$ .append(getTypeName()) .append(' ') .append(getName()) .append(' ') .append(getConstant()) .append('}') .toString(); } }
public static FieldInfo createField(byte classFileBytes[], int offsets[], int offset, long version) { FieldInfo fieldInfo = new FieldInfo(classFileBytes, offsets, offset, version); int attributesCount = fieldInfo.u2At(6); int readOffset = 8; AnnotationInfo[] annotations = null; int utf8Offset = fieldInfo.constantPoolOffsets[fieldInfo.u2At(readOffset)] - fieldInfo.structOffset; char[] attributeName = fieldInfo.utf8At(utf8Offset + 3, fieldInfo.u2At(utf8Offset + 1)); if (attributeName.length > 0) { switch(attributeName[0]) { case 'S' : if (CharOperation.equals(AttributeNamesConstants.SignatureName, attributeName)) fieldInfo.signatureUtf8Offset = fieldInfo.constantPoolOffsets[fieldInfo.u2At(readOffset + 6)] - fieldInfo.structOffset; break; case 'R' : TypeAnnotationInfo[] decodedTypeAnnotations = null; if (CharOperation.equals(attributeName, AttributeNamesConstants.RuntimeVisibleAnnotationsName)) { decodedAnnotations = fieldInfo.decodeAnnotations(readOffset, true); } else if (CharOperation.equals(attributeName, AttributeNamesConstants.RuntimeInvisibleAnnotationsName)) { decodedAnnotations = fieldInfo.decodeAnnotations(readOffset, false); } else if (CharOperation.equals(attributeName, AttributeNamesConstants.RuntimeVisibleTypeAnnotationsName)) { decodedTypeAnnotations = fieldInfo.decodeTypeAnnotations(readOffset, true); } else if (CharOperation.equals(attributeName, AttributeNamesConstants.RuntimeInvisibleTypeAnnotationsName)) { decodedTypeAnnotations = fieldInfo.decodeTypeAnnotations(readOffset, false); readOffset += (6 + fieldInfo.u4At(readOffset + 2));
for (int i = 0, max = fields.length; i < max; i++) { FieldInfo field = fields[i]; char[] fieldName = field.getName(); char[] fieldType = decodeFieldType(replace('/', '.', field.getTypeName())); addFieldDeclaration(fieldType, fieldName); annotations = field.getAnnotations(); if (annotations != null) { for (int a=0, length=annotations.length; a<length; a++) { tagBits = field.getTagBits() & TagBits.AllStandardAnnotationsMask; if (tagBits != 0) { addBinaryStandardAnnotations(tagBits);
this.fields = new FieldInfo[this.fieldsCount]; for (int i = 0; i < this.fieldsCount; i++) { field = FieldInfo.createField(this.reference, this.constantPoolOffsets, readOffset); this.fields[i] = field; readOffset += field.sizeInBytes();
for (int i = 0, max = fields.length; i < max; i++) { FieldInfo field = fields[i]; if (checkAnnotations(typeReferencePattern, field.getAnnotations(), field.getTagBits())) { IField fieldHandle = classFileBinaryType.getField(new String(field.getName())); TypeReferenceMatch match = new TypeReferenceMatch(fieldHandle, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
if (hasConstant()) { Constant fieldConstant = getConstant(); switch (fieldConstant.typeID()) { case TypeIds.T_int :
/** * Return true if the field is a synthetic field, false otherwise. * @return boolean */ public boolean isSynthetic() { return (getModifiers() & ClassFileConstants.AccSynthetic) != 0; } private void readConstantAttribute() {
/** * Return true if the field has a constant value attribute, false otherwise. * @return boolean */ public boolean hasConstant() { return getConstant() != Constant.NotAConstant; } /**
/** * This method is used to fully initialize the contents of the receiver. All methodinfos, fields infos * will be therefore fully initialized and we can get rid of the bytes. */ protected void initialize() { getModifiers(); getName(); getConstant(); getTypeName(); getGenericSignature(); reset(); } /**
public static FieldInfo createField(byte classFileBytes[], int offsets[], int offset) { FieldInfo fieldInfo = new FieldInfo(classFileBytes, offsets, offset); int attributesCount = fieldInfo.u2At(6); int readOffset = 8; AnnotationInfo[] annotations = null; int utf8Offset = fieldInfo.constantPoolOffsets[fieldInfo.u2At(readOffset)] - fieldInfo.structOffset; char[] attributeName = fieldInfo.utf8At(utf8Offset + 3, fieldInfo.u2At(utf8Offset + 1)); if (attributeName.length > 0) { switch(attributeName[0]) { case 'S' : if (CharOperation.equals(AttributeNamesConstants.SignatureName, attributeName)) fieldInfo.signatureUtf8Offset = fieldInfo.constantPoolOffsets[fieldInfo.u2At(readOffset + 6)] - fieldInfo.structOffset; break; case 'R' : TypeAnnotationInfo[] decodedTypeAnnotations = null; if (CharOperation.equals(attributeName, AttributeNamesConstants.RuntimeVisibleAnnotationsName)) { decodedAnnotations = fieldInfo.decodeAnnotations(readOffset, true); } else if (CharOperation.equals(attributeName, AttributeNamesConstants.RuntimeInvisibleAnnotationsName)) { decodedAnnotations = fieldInfo.decodeAnnotations(readOffset, false); } else if (CharOperation.equals(attributeName, AttributeNamesConstants.RuntimeVisibleTypeAnnotationsName)) { decodedTypeAnnotations = fieldInfo.decodeTypeAnnotations(readOffset, true); } else if (CharOperation.equals(attributeName, AttributeNamesConstants.RuntimeInvisibleTypeAnnotationsName)) { decodedTypeAnnotations = fieldInfo.decodeTypeAnnotations(readOffset, false); readOffset += (6 + fieldInfo.u4At(readOffset + 2));
protected void toStringContent(StringBuffer buffer) { int modifiers = getModifiers(); buffer .append('{') .append( ((modifiers & ClassFileConstants.AccDeprecated) != 0 ? "deprecated " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0001) == 1 ? "public " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0002) == 0x0002 ? "private " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0004) == 0x0004 ? "protected " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0008) == 0x000008 ? "static " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0010) == 0x0010 ? "final " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0040) == 0x0040 ? "volatile " : Util.EMPTY_STRING) //$NON-NLS-1$ + ((modifiers & 0x0080) == 0x0080 ? "transient " : Util.EMPTY_STRING)) //$NON-NLS-1$ .append(getTypeName()) .append(' ') .append(getName()) .append(' ') .append(getConstant()) .append('}') .toString(); } }
for (int i = 0, max = fields.length; i < max; i++) { FieldInfo field = fields[i]; char[] fieldName = field.getName(); char[] fieldType = decodeFieldType(replace('/', '.', field.getTypeName())); addFieldDeclaration(fieldType, fieldName); annotations = field.getAnnotations(); if (annotations != null) { for (int a=0, length=annotations.length; a<length; a++) { tagBits = field.getTagBits() & TagBits.AllStandardAnnotationsMask; if (tagBits != 0) { addBinaryStandardAnnotations(tagBits);
this.fields = new FieldInfo[this.fieldsCount]; for (int i = 0; i < this.fieldsCount; i++) { field = FieldInfo.createField(this.reference, this.constantPoolOffsets, readOffset); this.fields[i] = field; readOffset += field.sizeInBytes();
for (int i = 0, max = fields.length; i < max; i++) { FieldInfo field = fields[i]; if (checkAnnotations(typeReferencePattern, field.getAnnotations(), field.getTagBits())) { IField fieldHandle = classFileBinaryType.getField(new String(field.getName())); TypeReferenceMatch match = new TypeReferenceMatch(fieldHandle, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
if (hasConstant()) { Constant fieldConstant = getConstant(); switch (fieldConstant.typeID()) { case TypeIds.T_int :
/** * Return true if the field is a synthetic field, false otherwise. * @return boolean */ public boolean isSynthetic() { return (getModifiers() & ClassFileConstants.AccSynthetic) != 0; } private void readConstantAttribute() {