コード例 #1
0
ファイル: ClassFile.java プロジェクト: patrikbeno/jackie
  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();
    }
  }
コード例 #2
0
ファイル: ClassFile.java プロジェクト: patrikbeno/jackie
 public FieldInfo getField(String name) {
   // fixme performance
   for (FieldInfo f : fields()) {
     if (f.name().equals(name)) {
       return f;
     }
   }
   return null;
 }
コード例 #3
0
ファイル: ClassFile.java プロジェクト: patrikbeno/jackie
 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();
 }