290 // and directly resolve constant pool entries to load classes. The |
290 // and directly resolve constant pool entries to load classes. The |
291 // split-verifier can accept either Class entries or UnresolvedClass |
291 // split-verifier can accept either Class entries or UnresolvedClass |
292 // entries in the input constant pool. We revert the appended copy |
292 // entries in the input constant pool. We revert the appended copy |
293 // back to UnresolvedClass so that either verifier will be happy |
293 // back to UnresolvedClass so that either verifier will be happy |
294 // with the constant pool entry. |
294 // with the constant pool entry. |
|
295 // |
|
296 // this is an indirect CP entry so it needs special handling |
295 case JVM_CONSTANT_Class: |
297 case JVM_CONSTANT_Class: |
|
298 case JVM_CONSTANT_UnresolvedClass: |
296 { |
299 { |
297 // revert the copy to JVM_CONSTANT_UnresolvedClass |
300 int name_i = scratch_cp->klass_name_index_at(scratch_i); |
298 (*merge_cp_p)->unresolved_klass_at_put(*merge_cp_length_p, |
301 int new_name_i = find_or_append_indirect_entry(scratch_cp, name_i, merge_cp_p, |
299 scratch_cp->klass_name_at(scratch_i)); |
302 merge_cp_length_p, THREAD); |
300 |
303 |
|
304 if (new_name_i != name_i) { |
|
305 log_trace(redefine, class, constantpool) |
|
306 ("Class entry@%d name_index change: %d to %d", |
|
307 *merge_cp_length_p, name_i, new_name_i); |
|
308 } |
|
309 |
|
310 (*merge_cp_p)->temp_unresolved_klass_at_put(*merge_cp_length_p, new_name_i); |
301 if (scratch_i != *merge_cp_length_p) { |
311 if (scratch_i != *merge_cp_length_p) { |
302 // The new entry in *merge_cp_p is at a different index than |
312 // The new entry in *merge_cp_p is at a different index than |
303 // the new entry in scratch_cp so we need to map the index values. |
313 // the new entry in scratch_cp so we need to map the index values. |
304 map_index(scratch_cp, scratch_i, *merge_cp_length_p); |
314 map_index(scratch_cp, scratch_i, *merge_cp_length_p); |
305 } |
315 } |
328 case JVM_CONSTANT_Utf8: // fall through |
338 case JVM_CONSTANT_Utf8: // fall through |
329 |
339 |
330 // This was an indirect CP entry, but it has been changed into |
340 // This was an indirect CP entry, but it has been changed into |
331 // Symbol*s so this entry can be directly appended. |
341 // Symbol*s so this entry can be directly appended. |
332 case JVM_CONSTANT_String: // fall through |
342 case JVM_CONSTANT_String: // fall through |
333 |
|
334 // These were indirect CP entries, but they have been changed into |
|
335 // Symbol*s so these entries can be directly appended. |
|
336 case JVM_CONSTANT_UnresolvedClass: // fall through |
|
337 { |
343 { |
338 ConstantPool::copy_entry_to(scratch_cp, scratch_i, *merge_cp_p, *merge_cp_length_p, |
344 ConstantPool::copy_entry_to(scratch_cp, scratch_i, *merge_cp_p, *merge_cp_length_p, |
339 THREAD); |
345 THREAD); |
340 |
346 |
341 if (scratch_i != *merge_cp_length_p) { |
347 if (scratch_i != *merge_cp_length_p) { |
502 map_index(scratch_cp, scratch_i, *merge_cp_length_p); |
508 map_index(scratch_cp, scratch_i, *merge_cp_length_p); |
503 } |
509 } |
504 (*merge_cp_length_p)++; |
510 (*merge_cp_length_p)++; |
505 } break; |
511 } break; |
506 |
512 |
507 // At this stage, Class or UnresolvedClass could be here, but not |
513 // At this stage, Class or UnresolvedClass could be in scratch_cp, but not |
508 // ClassIndex |
514 // ClassIndex |
509 case JVM_CONSTANT_ClassIndex: // fall through |
515 case JVM_CONSTANT_ClassIndex: // fall through |
510 |
516 |
511 // Invalid is used as the tag for the second constant pool entry |
517 // Invalid is used as the tag for the second constant pool entry |
512 // occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should |
518 // occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should |
1268 case JVM_CONSTANT_Class: |
1274 case JVM_CONSTANT_Class: |
1269 case JVM_CONSTANT_UnresolvedClass: |
1275 case JVM_CONSTANT_UnresolvedClass: |
1270 // revert the copy to JVM_CONSTANT_UnresolvedClass |
1276 // revert the copy to JVM_CONSTANT_UnresolvedClass |
1271 // May be resolving while calling this so do the same for |
1277 // May be resolving while calling this so do the same for |
1272 // JVM_CONSTANT_UnresolvedClass (klass_name_at() deals with transition) |
1278 // JVM_CONSTANT_UnresolvedClass (klass_name_at() deals with transition) |
1273 (*merge_cp_p)->unresolved_klass_at_put(old_i, |
1279 (*merge_cp_p)->temp_unresolved_klass_at_put(old_i, |
1274 old_cp->klass_name_at(old_i)); |
1280 old_cp->klass_name_index_at(old_i)); |
1275 break; |
1281 break; |
1276 |
1282 |
1277 case JVM_CONSTANT_Double: |
1283 case JVM_CONSTANT_Double: |
1278 case JVM_CONSTANT_Long: |
1284 case JVM_CONSTANT_Long: |
1279 // just copy the entry to *merge_cp_p, but double and long take |
1285 // just copy the entry to *merge_cp_p, but double and long take |
3100 } |
3106 } |
3101 scratch_cp = smaller_cp; |
3107 scratch_cp = smaller_cp; |
3102 |
3108 |
3103 // attach new constant pool to klass |
3109 // attach new constant pool to klass |
3104 scratch_class->set_constants(scratch_cp()); |
3110 scratch_class->set_constants(scratch_cp()); |
|
3111 scratch_cp->initialize_unresolved_klasses(loader_data, CHECK); |
3105 |
3112 |
3106 int i; // for portability |
3113 int i; // for portability |
3107 |
3114 |
3108 // update each field in klass to use new constant pool indices as needed |
3115 // update each field in klass to use new constant pool indices as needed |
3109 for (JavaFieldStream fs(scratch_class); !fs.done(); fs.next()) { |
3116 for (JavaFieldStream fs(scratch_class); !fs.done(); fs.next()) { |