< prev index next >

src/hotspot/share/prims/jvmtiRedefineClasses.cpp

Print this page

 316     log_info(redefine, class, timer)
 317       ("vm_op: all=" JULONG_FORMAT "  prologue=" JULONG_FORMAT "  doit=" JULONG_FORMAT,
 318        all_time, (julong)_timer_vm_op_prologue.milliseconds(), doit_time);
 319     log_info(redefine, class, timer)
 320       ("redefine_single_class: phase1=" JULONG_FORMAT "  phase2=" JULONG_FORMAT,
 321        (julong)_timer_rsc_phase1.milliseconds(), (julong)_timer_rsc_phase2.milliseconds());
 322   }
 323 }
 324 
 325 bool VM_RedefineClasses::is_modifiable_class(oop klass_mirror) {
 326   // classes for primitives cannot be redefined
 327   if (java_lang_Class::is_primitive(klass_mirror)) {
 328     return false;
 329   }
 330   Klass* k = java_lang_Class::as_Klass(klass_mirror);
 331   // classes for arrays cannot be redefined
 332   if (k == NULL || !k->is_instance_klass()) {
 333     return false;
 334   }
 335 









 336   // Cannot redefine or retransform a hidden class.
 337   if (InstanceKlass::cast(k)->is_hidden()) {
 338     return false;
 339   }
 340   return true;
 341 }
 342 
 343 // Append the current entry at scratch_i in scratch_cp to *merge_cp_p
 344 // where the end of *merge_cp_p is specified by *merge_cp_length_p. For
 345 // direct CP entries, there is just the current entry to append. For
 346 // indirect and double-indirect CP entries, there are zero or more
 347 // referenced CP entries along with the current entry to append.
 348 // Indirect and double-indirect CP entries are handled by recursive
 349 // calls to append_entry() as needed. The referenced CP entries are
 350 // always appended to *merge_cp_p before the referee CP entry. These
 351 // referenced CP entries may already exist in *merge_cp_p in which case
 352 // there is nothing extra to append and only the current entry is
 353 // appended.
 354 void VM_RedefineClasses::append_entry(const constantPoolHandle& scratch_cp,
 355        int scratch_i, constantPoolHandle *merge_cp_p, int *merge_cp_length_p) {

 581       if (scratch_i != *merge_cp_length_p) {
 582         // The new entry in *merge_cp_p is at a different index than
 583         // the new entry in scratch_cp so we need to map the index values.
 584         map_index(scratch_cp, scratch_i, *merge_cp_length_p);
 585       }
 586       (*merge_cp_length_p)++;
 587     } break;
 588 
 589     // At this stage, Class or UnresolvedClass could be in scratch_cp, but not
 590     // ClassIndex
 591     case JVM_CONSTANT_ClassIndex: // fall through
 592 
 593     // Invalid is used as the tag for the second constant pool entry
 594     // occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should
 595     // not be seen by itself.
 596     case JVM_CONSTANT_Invalid: // fall through
 597 
 598     // At this stage, String could be here, but not StringIndex
 599     case JVM_CONSTANT_StringIndex: // fall through
 600 
 601     // At this stage JVM_CONSTANT_UnresolvedClassInError should not be
 602     // here
 603     case JVM_CONSTANT_UnresolvedClassInError: // fall through
 604 
 605     default:
 606     {
 607       // leave a breadcrumb
 608       jbyte bad_value = scratch_cp->tag_at(scratch_i).value();
 609       ShouldNotReachHere();
 610     } break;
 611   } // end switch tag value
 612 } // end append_entry()
 613 
 614 
 615 int VM_RedefineClasses::find_or_append_indirect_entry(const constantPoolHandle& scratch_cp,
 616       int ref_i, constantPoolHandle *merge_cp_p, int *merge_cp_length_p) {
 617 
 618   int new_ref_i = ref_i;
 619   bool match = (ref_i < *merge_cp_length_p) &&
 620                scratch_cp->compare_entry_to(ref_i, *merge_cp_p, ref_i);
 621 
 622   if (!match) {

 316     log_info(redefine, class, timer)
 317       ("vm_op: all=" JULONG_FORMAT "  prologue=" JULONG_FORMAT "  doit=" JULONG_FORMAT,
 318        all_time, (julong)_timer_vm_op_prologue.milliseconds(), doit_time);
 319     log_info(redefine, class, timer)
 320       ("redefine_single_class: phase1=" JULONG_FORMAT "  phase2=" JULONG_FORMAT,
 321        (julong)_timer_rsc_phase1.milliseconds(), (julong)_timer_rsc_phase2.milliseconds());
 322   }
 323 }
 324 
 325 bool VM_RedefineClasses::is_modifiable_class(oop klass_mirror) {
 326   // classes for primitives cannot be redefined
 327   if (java_lang_Class::is_primitive(klass_mirror)) {
 328     return false;
 329   }
 330   Klass* k = java_lang_Class::as_Klass(klass_mirror);
 331   // classes for arrays cannot be redefined
 332   if (k == NULL || !k->is_instance_klass()) {
 333     return false;
 334   }
 335 
 336   // Cannot redefine or retransform interface java.lang.IdentityObject.
 337   if (k->name() == vmSymbols::java_lang_IdentityObject()) {
 338     return false;
 339   }
 340   // Cannot redefine or retransform interface java.lang.PrimitiveObject.
 341   if (k->name() == vmSymbols::java_lang_PrimitiveObject()) {
 342     return false;
 343   }
 344 
 345   // Cannot redefine or retransform a hidden class.
 346   if (InstanceKlass::cast(k)->is_hidden()) {
 347     return false;
 348   }
 349   return true;
 350 }
 351 
 352 // Append the current entry at scratch_i in scratch_cp to *merge_cp_p
 353 // where the end of *merge_cp_p is specified by *merge_cp_length_p. For
 354 // direct CP entries, there is just the current entry to append. For
 355 // indirect and double-indirect CP entries, there are zero or more
 356 // referenced CP entries along with the current entry to append.
 357 // Indirect and double-indirect CP entries are handled by recursive
 358 // calls to append_entry() as needed. The referenced CP entries are
 359 // always appended to *merge_cp_p before the referee CP entry. These
 360 // referenced CP entries may already exist in *merge_cp_p in which case
 361 // there is nothing extra to append and only the current entry is
 362 // appended.
 363 void VM_RedefineClasses::append_entry(const constantPoolHandle& scratch_cp,
 364        int scratch_i, constantPoolHandle *merge_cp_p, int *merge_cp_length_p) {

 590       if (scratch_i != *merge_cp_length_p) {
 591         // The new entry in *merge_cp_p is at a different index than
 592         // the new entry in scratch_cp so we need to map the index values.
 593         map_index(scratch_cp, scratch_i, *merge_cp_length_p);
 594       }
 595       (*merge_cp_length_p)++;
 596     } break;
 597 
 598     // At this stage, Class or UnresolvedClass could be in scratch_cp, but not
 599     // ClassIndex
 600     case JVM_CONSTANT_ClassIndex: // fall through
 601 
 602     // Invalid is used as the tag for the second constant pool entry
 603     // occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should
 604     // not be seen by itself.
 605     case JVM_CONSTANT_Invalid: // fall through
 606 
 607     // At this stage, String could be here, but not StringIndex
 608     case JVM_CONSTANT_StringIndex: // fall through
 609 
 610     // At this stage JVM_CONSTANT_UnresolvedClassInError should not be here

 611     case JVM_CONSTANT_UnresolvedClassInError: // fall through
 612 
 613     default:
 614     {
 615       // leave a breadcrumb
 616       jbyte bad_value = scratch_cp->tag_at(scratch_i).value();
 617       ShouldNotReachHere();
 618     } break;
 619   } // end switch tag value
 620 } // end append_entry()
 621 
 622 
 623 int VM_RedefineClasses::find_or_append_indirect_entry(const constantPoolHandle& scratch_cp,
 624       int ref_i, constantPoolHandle *merge_cp_p, int *merge_cp_length_p) {
 625 
 626   int new_ref_i = ref_i;
 627   bool match = (ref_i < *merge_cp_length_p) &&
 628                scratch_cp->compare_entry_to(ref_i, *merge_cp_p, ref_i);
 629 
 630   if (!match) {
< prev index next >