コード例 #1
0
ファイル: ClassFile.java プロジェクト: cogumbreiro/x10
  /**
   * Read the class's attributes. Since none of the attributes are required, just read the length of
   * each attribute and skip that many bytes.
   *
   * @param in The stream from which to read.
   * @exception IOException If an error occurs while reading.
   */
  public void readAttributes(DataInputStream in) throws IOException {
    int numAttributes = in.readUnsignedShort();

    attrs = new Attribute[numAttributes];

    for (int i = 0; i < numAttributes; i++) {
      int nameIndex = in.readUnsignedShort();
      int length = in.readInt();
      String name = (String) constants[nameIndex].value();
      Attribute a = createAttribute(in, name, nameIndex, length);
      if (a != null) {
        attrs[i] = a;
      } else {
        long n = in.skip(length);
        if (n != length) {
          throw new EOFException();
        }
      }
    }
  }