Ejemplo 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();
    }
  }
Ejemplo n.º 2
0
 public MethodInfo getMethod(String name, String descriptor) {
   // fixme performance
   for (MethodInfo m : methods()) {
     if (m.name().equals(name) && m.descriptor().equals(descriptor)) {
       return m;
     }
   }
   return null;
 }
Ejemplo n.º 3
0
 private void registerConstants(ConstantPool pool) {
   classname = pool.register(classname);
   superclass = pool.register(superclass);
   interfaces = Helper.register(interfaces, pool);
   for (FieldInfo f : iterable(fields)) {
     f.registerConstants(pool);
   }
   for (MethodInfo m : iterable(methods)) {
     m.registerConstants(pool);
   }
   for (AttributeInfo a : iterable(attributes)) {
     a.registerConstants(pool);
   }
   pool.rebuild();
 }