+
+ public static class NameAndType {
+ String name;
+ String type;
+ NameAndType(String name, String type) { this.name = name; this.type = type; }
+ public boolean equals(Object o_) {
+ if(!(o_ instanceof NameAndType)) return false;
+ NameAndType o = (NameAndType) o_;
+ return o.name.equals(name) && o.type.equals(type);
+ }
+ public int hashCode() { return name.hashCode() ^ type.hashCode(); }
+ }
+
+ public static abstract class FieldMethodRef {
+ Type.Object klass;
+ NameAndType nameAndType;
+ FieldMethodRef(Type.Object klass, NameAndType nameAndType) { this.klass = klass; this.nameAndType = nameAndType; }
+ public boolean equals(Object o_) {
+ if(!(o_ instanceof FieldMethodRef)) return false;
+ FieldMethodRef o = (FieldMethodRef) o_;
+ return o.klass.equals(klass) && o.nameAndType.equals(nameAndType);
+ }
+ public int hashCode() { return klass.hashCode() ^ nameAndType.hashCode(); }
+ }
+
+ public static class InterfaceMethodRef extends FieldMethodRef {
+ public InterfaceMethodRef(MethodRef r) { super(r.klass,r.nameAndType); }
+ public InterfaceMethodRef(Type.Object c, NameAndType t) { super(c,t); }
+ }
+
+ static class AttrGen {
+ private final CPGen cp;
+ private final Hashtable ht = new Hashtable();
+
+ public AttrGen(CPGen cp) {
+ this.cp = cp;
+ }
+
+ public void add(String s, Object data) {
+ cp.addUtf8(s);
+ ht.put(s,data);
+ }
+
+ public boolean contains(String s) { return ht.get(s) != null; }
+
+ public int size() { return ht.size(); }
+
+ public void dump(DataOutput o) throws IOException {
+ for(Enumeration e = ht.keys(); e.hasMoreElements();) {
+ String name = (String) e.nextElement();
+ Object val = ht.get(name);
+ o.writeShort(cp.getUtf8Index(name));
+ if(val instanceof byte[]) {
+ byte[] buf = (byte[]) val;
+ o.writeInt(buf.length);
+ o.write(buf);
+ } else if(val instanceof CPGen.Ent) {
+ o.writeInt(2);
+ o.writeShort(((CPGen.Ent)val).getIndex());
+ } else {
+ throw new Error("should never happen");
+ }
+ }
+ }
+ }
+
+ /*public static void main(String[] args) throws Exception {
+ Type.Object me = new Type.Object("Test");