src/hotspot/share/prims/jvmtiRedefineClasses.cpp
changeset 54645 05aaccf7d558
parent 54585 3452d108d06d
child 54786 ebf733a324d4
equal deleted inserted replaced
54644:8d52b4c6f9d8 54645:05aaccf7d558
    88 }
    88 }
    89 
    89 
    90 // If any of the classes are being redefined, wait
    90 // If any of the classes are being redefined, wait
    91 // Parallel constant pool merging leads to indeterminate constant pools.
    91 // Parallel constant pool merging leads to indeterminate constant pools.
    92 void VM_RedefineClasses::lock_classes() {
    92 void VM_RedefineClasses::lock_classes() {
    93   MutexLocker ml(RedefineClasses_lock);
    93   MonitorLocker ml(RedefineClasses_lock);
    94   bool has_redefined;
    94   bool has_redefined;
    95   do {
    95   do {
    96     has_redefined = false;
    96     has_redefined = false;
    97     // Go through classes each time until none are being redefined.
    97     // Go through classes each time until none are being redefined.
    98     for (int i = 0; i < _class_count; i++) {
    98     for (int i = 0; i < _class_count; i++) {
    99       if (get_ik(_class_defs[i].klass)->is_being_redefined()) {
    99       if (get_ik(_class_defs[i].klass)->is_being_redefined()) {
   100         RedefineClasses_lock->wait();
   100         ml.wait();
   101         has_redefined = true;
   101         has_redefined = true;
   102         break;  // for loop
   102         break;  // for loop
   103       }
   103       }
   104     }
   104     }
   105   } while (has_redefined);
   105   } while (has_redefined);
   106   for (int i = 0; i < _class_count; i++) {
   106   for (int i = 0; i < _class_count; i++) {
   107     get_ik(_class_defs[i].klass)->set_is_being_redefined(true);
   107     get_ik(_class_defs[i].klass)->set_is_being_redefined(true);
   108   }
   108   }
   109   RedefineClasses_lock->notify_all();
   109   ml.notify_all();
   110 }
   110 }
   111 
   111 
   112 void VM_RedefineClasses::unlock_classes() {
   112 void VM_RedefineClasses::unlock_classes() {
   113   MutexLocker ml(RedefineClasses_lock);
   113   MonitorLocker ml(RedefineClasses_lock);
   114   for (int i = 0; i < _class_count; i++) {
   114   for (int i = 0; i < _class_count; i++) {
   115     assert(get_ik(_class_defs[i].klass)->is_being_redefined(),
   115     assert(get_ik(_class_defs[i].klass)->is_being_redefined(),
   116            "should be being redefined to get here");
   116            "should be being redefined to get here");
   117     get_ik(_class_defs[i].klass)->set_is_being_redefined(false);
   117     get_ik(_class_defs[i].klass)->set_is_being_redefined(false);
   118   }
   118   }
   119   RedefineClasses_lock->notify_all();
   119   ml.notify_all();
   120 }
   120 }
   121 
   121 
   122 bool VM_RedefineClasses::doit_prologue() {
   122 bool VM_RedefineClasses::doit_prologue() {
   123   if (_class_count == 0) {
   123   if (_class_count == 0) {
   124     _res = JVMTI_ERROR_NONE;
   124     _res = JVMTI_ERROR_NONE;