private static final int NO_CODE = -1;
private static final int FINISHED = -2;
-
+
+ private final ClassFile owner;
private final CPGen cp;
private final String name;
private final Type ret;
// FIXME: attrs, body
}
- MethodGen(CPGen cp, DataInput in) throws IOException {
+ MethodGen(CPGen cp, DataInput in, ClassFile owner) throws IOException {
this.cp = cp;
+ this.owner = owner;
flags = in.readShort();
name = cp.getUtf8ByIndex(in.readShort());
String descriptor = cp.getUtf8ByIndex(in.readShort());
this.ret = ret;
this.args = args;
this.flags = flags;
+ this.owner = owner;
attrs = new ClassFile.AttrGen(cp);
codeAttrs = new ClassFile.AttrGen(cp);
cp.addUtf8(name);
- cp.addUtf8(getDescriptor());
+ cp.addUtf8(owner.getType().method(name, ret, args).getDescriptor());
if((owner.flags & ACC_INTERFACE) != 0 || (flags & (ACC_ABSTRACT|ACC_NATIVE)) != 0) size = capacity = -1;
maxLocals = Math.max(args.length + (flags&ACC_STATIC)==0 ? 1 : 0, 4);
}
- /** Returns the descriptor string for this method */
- public String getDescriptor() { return MethodRef.getDescriptor(ret, args); }
-
private class ExnTableEnt {
public int start;
public int end;
if(arg instanceof Long || arg instanceof Double) op = LDC2_W;
break;
- case INVOKEINTERFACE:
- if(arg instanceof MethodRef) arg = new MethodRef.I((MethodRef)arg);
+ case INVOKEINTERFACE: {
break;
+ }
}
int opdata = OP_DATA[op&0xff];
- if((opdata&OP_CPENT_FLAG) != 0 && !(arg instanceof CPGen.Ent))
- arg = cp.add(arg);
+ if((opdata&OP_CPENT_FLAG) != 0 && !(arg instanceof CPGen.Ent)) {
+ if (op==INVOKEINTERFACE) arg = cp.add(arg, true);
+ else arg = cp.add(arg);
+ }
else if((opdata&OP_VALID_FLAG) == 0)
throw new IllegalArgumentException("unknown bytecode");
this.op[pos] = op;
void dump(DataOutput o) throws IOException {
o.writeShort(flags);
o.writeShort(cp.getUtf8Index(name));
- o.writeShort(cp.getUtf8Index(getDescriptor()));
+ o.writeShort(cp.getUtf8Index(owner.getType().method(name, ret, args).getDescriptor()));
o.writeShort(attrs.size());
attrs.dump(o);
}