public final Ent addNameAndType(String name, String descriptor) { return add(new NameAndTypeKey(name, descriptor)); }
public final Ent addUtf8(String s) { return add(new Utf8Key(s)); }
- public final Ent add(Object o) {
+ public final Ent add(Object o) { return add(o, false); }
+ public final Ent add(Object o, boolean invokeInterface) {
if(state == SEALED) throw new IllegalStateException("constant pool is sealed");
Ent ent = get(o);
ent = ce;
} else if(o instanceof MemberRef) {
MemberRef key = (MemberRef) o;
- int tag = o instanceof FieldRef ? 9 : o instanceof MethodRef ? 10 : o instanceof MethodRef.I ? 11 : 0;
+ int tag = invokeInterface ? 11 : o instanceof FieldRef ? 9 : o instanceof MethodRef ? 10 : 0;
if(tag == 0) throw new Error("should never happen");
CPRefEnt ce = new CPRefEnt(tag);
ce.e1 = add(key.klass);
if(arg instanceof Long || arg instanceof Double) op = LDC2_W;
break;
case INVOKEINTERFACE: {
- MethodRef mr = (MethodRef)arg;
- if(arg instanceof MethodRef) arg = new MethodRef.I(mr.klass, mr.name, mr.returnType, mr.argTypes);
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;
sb.append(returnType.getDescriptor());
return sb.toString();
}
-
- /** MethodRef class used for the INVOKEINTERFACE bytecode. Although this contains the same
- data as a normal MethodRef, these are treated differently in the byte code format. In general,
- users don't need to be concerned with this though because MethodRef's are automatically converted
- to MethodRef.I's when they are applied to an INVOKEINTERFACE bytecode */
- public static class I extends MethodRef {
- public I(Type.Class c, String name, Type ret, Type[] args) { super(c, name, ret, args); }
- }
}