src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java

Print this page
rev 10452 : imported patch lang-Typos


 192             this.index = index;
 193             this.placeholder = placeholder;
 194             this.value = value;
 195         }
 196         public String toString() {
 197             return "CpPatch/index="+index+",placeholder="+placeholder+",value="+value;
 198         }
 199     }
 200 
 201     Map<Object, CpPatch> cpPatches = new HashMap<>();
 202 
 203     int cph = 0;  // for counting constant placeholders
 204 
 205     String constantPlaceholder(Object arg) {
 206         String cpPlaceholder = "CONSTANT_PLACEHOLDER_" + cph++;
 207         if (DUMP_CLASS_FILES) cpPlaceholder += " <<" + arg.toString() + ">>";  // debugging aid
 208         if (cpPatches.containsKey(cpPlaceholder)) {
 209             throw new InternalError("observed CP placeholder twice: " + cpPlaceholder);
 210         }
 211         // insert placeholder in CP and remember the patch
 212         int index = cw.newConst((Object) cpPlaceholder);  // TODO check if aready in the constant pool
 213         cpPatches.put(cpPlaceholder, new CpPatch(index, cpPlaceholder, arg));
 214         return cpPlaceholder;
 215     }
 216 
 217     Object[] cpPatches(byte[] classFile) {
 218         int size = getConstantPoolSize(classFile);
 219         Object[] res = new Object[size];
 220         for (CpPatch p : cpPatches.values()) {
 221             if (p.index >= size)
 222                 throw new InternalError("in cpool["+size+"]: "+p+"\n"+Arrays.toString(Arrays.copyOf(classFile, 20)));
 223             res[p.index] = p.value;
 224         }
 225         return res;
 226     }
 227 
 228     /**
 229      * Extract the number of constant pool entries from a given class file.
 230      *
 231      * @param classFile the bytes of the class file in question.
 232      * @return the number of entries in the constant pool.




 192             this.index = index;
 193             this.placeholder = placeholder;
 194             this.value = value;
 195         }
 196         public String toString() {
 197             return "CpPatch/index="+index+",placeholder="+placeholder+",value="+value;
 198         }
 199     }
 200 
 201     Map<Object, CpPatch> cpPatches = new HashMap<>();
 202 
 203     int cph = 0;  // for counting constant placeholders
 204 
 205     String constantPlaceholder(Object arg) {
 206         String cpPlaceholder = "CONSTANT_PLACEHOLDER_" + cph++;
 207         if (DUMP_CLASS_FILES) cpPlaceholder += " <<" + arg.toString() + ">>";  // debugging aid
 208         if (cpPatches.containsKey(cpPlaceholder)) {
 209             throw new InternalError("observed CP placeholder twice: " + cpPlaceholder);
 210         }
 211         // insert placeholder in CP and remember the patch
 212         int index = cw.newConst((Object) cpPlaceholder);  // TODO check if already in the constant pool
 213         cpPatches.put(cpPlaceholder, new CpPatch(index, cpPlaceholder, arg));
 214         return cpPlaceholder;
 215     }
 216 
 217     Object[] cpPatches(byte[] classFile) {
 218         int size = getConstantPoolSize(classFile);
 219         Object[] res = new Object[size];
 220         for (CpPatch p : cpPatches.values()) {
 221             if (p.index >= size)
 222                 throw new InternalError("in cpool["+size+"]: "+p+"\n"+Arrays.toString(Arrays.copyOf(classFile, 20)));
 223             res[p.index] = p.value;
 224         }
 225         return res;
 226     }
 227 
 228     /**
 229      * Extract the number of constant pool entries from a given class file.
 230      *
 231      * @param classFile the bytes of the class file in question.
 232      * @return the number of entries in the constant pool.