Exemplo n.º 1
0
  public void load(XDataInput in) {
    newContext();
    try {
      magic = in.readInt();
      minor = in.readUnsignedShort();
      major = in.readUnsignedShort();

      pool = ConstantPool.create(true);

      pool.load(in, pool);

      flags = Flags.create(in, pool);
      classname = pool.getConstant(in.readUnsignedShort(), ClassRef.class);
      Log.debug("Loading class %s", classname.value());

      superclass = pool.getConstant(in.readUnsignedShort(), ClassRef.class);

      // interfaces
      {
        int count = in.readUnsignedShort();
        interfaces = new ArrayList<ClassRef>(count);
        while (count-- > 0) {
          ClassRef iface = pool.getConstant(in.readUnsignedShort(), ClassRef.class);
          interfaces.add(iface);
        }
      }

      // fields
      {
        int count = in.readUnsignedShort();
        fields = new ArrayList<FieldInfo>(count);
        while (count-- > 0) {
          FieldInfo f = new FieldInfo(this);
          f.load(in, pool);
          fields.add(f);
        }
      }

      // methods
      {
        int count = in.readUnsignedShort();
        methods = new ArrayList<MethodInfo>(count);
        while (count-- > 0) {
          MethodInfo m = new MethodInfo(this);
          m.load(in, pool);
          methods.add(m);
        }
      }

      attributes = AttributeHelper.loadAttributes(this, in);
      AttributeHelper.qdhRemoveUnsupportedAttributes(attributes);

      pool.close();

    } finally {
      closeContext();
    }
  }
Exemplo n.º 2
0
 public void save(XDataOutput out) {
   Log.debug("\t%s", this);
   out.writeByte(opcode);
   saveOperands(out);
 }