ILLEGAL_ACCESS_ERROR, ABSTRACT_METHOD_ERROR, UNSATISFIED_LINK_ERROR };
public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESPECIAL_INVOKEVIRTUAL = { INCOMPATIBLE_CLASS_CHANGE_ERROR,
NULL_POINTER_EXCEPTION, ABSTRACT_METHOD_ERROR, UNSATISFIED_LINK_ERROR };
+// public static final Class[] EXCS_INVOKEDYNAMIC = { BOOTSTRAP_METHOD_ERROR};
public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESTATIC = { INCOMPATIBLE_CLASS_CHANGE_ERROR,
UNSATISFIED_LINK_ERROR };
isInPackedState = true;
}
- static class BootstrapMethod {
+ public static class BootstrapMethod {
private int bootstrapMethodRef;
private int[] bootstrapArguments;
return bootstrapArguments;
}
- BootstrapMethod(int bootstrapMethodRef, int[] bootstrapArguments) {
+ public BootstrapMethod(int bootstrapMethodRef, int[] bootstrapArguments) {
this.bootstrapMethodRef = bootstrapMethodRef;
this.bootstrapArguments = bootstrapArguments;
}
}
}
+ public final int getLength() {
+ return 2 /*bootstrapMethodRef*/+
+ 2 /*number of arguments*/+
+ 2 * bootstrapArguments.length;
+ }
+
}
// Unpacks the byte array into the table
return addNameAndType(u8.getValue(), u8_2.getValue());
}
+
+ case Constants.CONSTANT_InvokeDynamic: {
+ ConstantInvokeDynamic cid = (ConstantInvokeDynamic)c;
+ int index1 = cid.getBootstrapMethodAttrIndex();
+ ConstantNameAndType cnat = (ConstantNameAndType)constants[cid.getNameAndTypeIndex()];
+ ConstantUtf8 name = (ConstantUtf8) constants[cnat.getNameIndex()];
+ ConstantUtf8 signature = (ConstantUtf8) constants[cnat.getSignatureIndex()];
+ int index2 = addNameAndType(name.getValue(), signature.getValue());
+ return addInvokeDynamic(index1,index2);
+ }
+
+ case Constants.CONSTANT_MethodHandle:
+ ConstantMethodHandle cmh = (ConstantMethodHandle)c;
+ return addMethodHandle(cmh.getReferenceKind(),addConstant(constants[cmh.getReferenceIndex()],cp));
case Constants.CONSTANT_Utf8:
return addUtf8(((ConstantUtf8) c).getValue());
case Constants.CONSTANT_Integer:
return addInteger(((ConstantInteger) c).getValue());
+
+ case Constants.CONSTANT_MethodType:
+ ConstantMethodType cmt = (ConstantMethodType)c;
+ return addMethodType(addConstant(constants[cmt.getDescriptorIndex()],cp));
case Constants.CONSTANT_InterfaceMethodref:
case Constants.CONSTANT_Methodref:
throw new RuntimeException("Unknown constant type " + c);
}
}
+
+ public int addMethodHandle(byte referenceKind, int referenceIndex) {
+ adjustSize();
+ int ret = poolSize;
+ pool[poolSize++] = new ConstantMethodHandle(referenceKind, referenceIndex);
+ return ret;
+ }
+
+ public int addMethodType(int descriptorIndex) {
+ adjustSize();
+ int ret = poolSize;
+ pool[poolSize++] = new ConstantMethodType(descriptorIndex);
+ return ret;
+ }
// OPTIMIZE should put it in the cache now
public int addMethodref(String class_name, String method_name, String signature) {
pool[poolSize++] = new ConstantMethodref(class_index, name_and_type_index);
return ret;
}
+
+ public int addInvokeDynamic(int bootstrapMethodIndex, int constantNameAndTypeIndex) {
+ adjustSize();
+ int ret = poolSize;
+ pool[poolSize++] = new ConstantInvokeDynamic(bootstrapMethodIndex, constantNameAndTypeIndex);
+ return ret;
+ }
public int addInterfaceMethodref(String class_name, String method_name, String signature) {
int ret = lookupInterfaceMethodref(class_name, method_name, signature);
public void replaceConstantPool(ConstantPool old_cp, ConstantPool new_cp) {
for (InstructionHandle ih = start; ih != null; ih = ih.next) {
Instruction i = ih.instruction;
-
if (i.isConstantPoolInstruction()) {
InstructionCP ci = (InstructionCP) i;
Constant c = old_cp.getConstant(ci.getIndex());
}
/**
- * Delete contents of list. Provides besser memory utilization, because the system then may reuse the instruction handles. This
+ * Delete contents of list. Provides better memory utilization, because the system then may reuse the instruction handles. This
* method is typically called right after <href="MethodGen.html#getMethod()">MethodGen.getMethod()</a>.
*/
public void dispose() {