@Override public FieldInfo get(int i) { return new FieldInfo(clazz, fields[i]); }
/** * Construct a new mock Field instance. * * @param clazz the class declaring the field * @param name the name of the field * @param type the Java field type * @param flags the field attributes * @return a mock field */ public static FieldInfo create(ClassInfo clazz, String name, Type type, short flags) { if (clazz == null) throw new IllegalArgumentException("Clazz can't be null"); if (name == null) throw new IllegalArgumentException("Name can't be null"); return new FieldInfo(clazz, Utils.toUTF8(name), type, flags); }
/** * Retrieves a field by the given name. Only fields declared in this class are available. * Locating inherited fields requires traversing the class hierarchy. * * @param name the name of the field * @return the field */ public final FieldInfo field(String name) { FieldInternal key = new FieldInternal(Utils.toUTF8(name), VoidType.VOID, (short)0); int i = Arrays.binarySearch(fields, key, FieldInternal.NAME_COMPARATOR); if (i < 0) { return null; } return new FieldInfo(this, fields[i]); }
private void processFieldInfo(DataInputStream data) throws IOException { int numFields = data.readUnsignedShort(); List<FieldInfo> fields = numFields > 0 ? new ArrayList<FieldInfo>(numFields) : Collections.<FieldInfo>emptyList(); for (int i = 0; i < numFields; i++) { short flags = (short) data.readUnsignedShort(); byte[] name = intern(decodeUtf8EntryAsBytes(data.readUnsignedShort())); Type type = parseType(decodeUtf8Entry(data.readUnsignedShort())); FieldInfo field = new FieldInfo(currentClass, name, type, flags); processAttributes(data, field); field.setAnnotations(elementAnnotations); elementAnnotations.clear(); fields.add(field); } this.fields = fields; }
private FieldInternal readFieldEntry(PackedDataInputStream stream) throws IOException { byte[] name = byteTable[stream.readPackedU32()]; short flags = (short) stream.readPackedU32(); Type type = typeTable[stream.readPackedU32()]; FieldInfo fieldInfo = new FieldInfo(); AnnotationInstance[] annotations = readAnnotations(stream, fieldInfo); FieldInternal fieldInternal = new FieldInternal(name, type, flags, annotations); fieldInfo.setFieldInternal(fieldInternal); return fieldInternal; }
Type type = readType(stream); short flags = stream.readShort(); target = new FieldInfo(clazz, Utils.toUTF8(name), type, flags); break;