--- a/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Wed Jul 05 18:20:00 2017 +0200
+++ b/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Fri Aug 17 13:42:25 2012 -0700
@@ -185,12 +185,17 @@
}
class CpPatch {
- int index;
- Object value;
- CpPatch(int index, Object value) {
+ final int index;
+ final String placeholder;
+ final Object value;
+ CpPatch(int index, String placeholder, Object value) {
this.index = index;
+ this.placeholder = placeholder;
this.value = value;
}
+ public String toString() {
+ return "CpPatch/index="+index+",placeholder="+placeholder+",value="+value;
+ }
}
Map<Object, CpPatch> cpPatches = new HashMap<>();
@@ -205,7 +210,7 @@
}
// insert placeholder in CP and remember the patch
int index = cw.newConst((Object) cpPlaceholder); // TODO check if aready in the constant pool
- cpPatches.put(cpPlaceholder, new CpPatch(index, arg));
+ cpPatches.put(cpPlaceholder, new CpPatch(index, cpPlaceholder, arg));
return cpPlaceholder;
}
@@ -213,7 +218,9 @@
int size = getConstantPoolSize(classFile);
Object[] res = new Object[size];
for (CpPatch p : cpPatches.values()) {
- res[p.index] = p.value;
+ if (p.index >= size)
+ throw new InternalError("in cpool["+size+"]: "+p+"\n"+Arrays.toString(Arrays.copyOf(classFile, 20)));
+ res[p.index] = p.value;
}
return res;
}