/** * Reads a <code>MethodInfo</code> from an input stream. * * @param cf The class file defining the method. * @param in The input stream to read from. * @return The method information read. * @throws IOException If an IO error occurs. */ public static MethodInfo read(ClassFile cf, DataInputStream in) throws IOException { int accessFlags = in.readUnsignedShort(); int nameIndex = in.readUnsignedShort(); int descriptorIndex = in.readUnsignedShort(); MethodInfo mi = new MethodInfo(cf, accessFlags, nameIndex, descriptorIndex); int attrCount = in.readUnsignedShort(); for (int j = 0; j < attrCount; j++) { AttributeInfo ai = mi.readAttribute(in); if (ai instanceof Signature) { mi.signatureAttr = (Signature) ai; } else if (ai instanceof Code) { mi.codeAttr = (Code) ai; } else if (ai != null) { mi.addAttribute(ai); } } return mi; }