src/share/vm/prims/jvmtiRedefineClasses.cpp

Print this page




3362            InstanceKlass::cast(_the_class_oop)->class_loader() != NULL;
3363     if (is_user_defined && ik->class_loader() == NULL) {
3364       return;
3365     }
3366 
3367     // Fix the vtable embedded in the_class and subclasses of the_class,
3368     // if one exists. We discard scratch_class and we don't keep an
3369     // InstanceKlass around to hold obsolete methods so we don't have
3370     // any other InstanceKlass embedded vtables to update. The vtable
3371     // holds the Method*s for virtual (but not final) methods.
3372     // Default methods, or concrete methods in interfaces are stored
3373     // in the vtable, so if an interface changes we need to check
3374     // adjust_method_entries() for every InstanceKlass, which will also
3375     // adjust the default method vtable indices.
3376     // We also need to adjust any default method entries that are
3377     // not yet in the vtable, because the vtable setup is in progress.
3378     // This must be done after we adjust the default_methods and
3379     // default_vtable_indices for methods already in the vtable.
3380     // If redefining Unsafe, walk all the vtables looking for entries.
3381     if (ik->vtable_length() > 0 && (_the_class_oop->is_interface()
3382         || _the_class_oop == SystemDictionary::misc_Unsafe_klass()
3383         || ik->is_subtype_of(_the_class_oop))) {
3384       // ik->vtable() creates a wrapper object; rm cleans it up
3385       ResourceMark rm(_thread);
3386 
3387       ik->vtable()->adjust_method_entries(the_class, &trace_name_printed);
3388       ik->adjust_default_methods(the_class, &trace_name_printed);
3389     }
3390 
3391     // If the current class has an itable and we are either redefining an
3392     // interface or if the current class is a subclass of the_class, then
3393     // we potentially have to fix the itable. If we are redefining an
3394     // interface, then we have to call adjust_method_entries() for
3395     // every InstanceKlass that has an itable since there isn't a
3396     // subclass relationship between an interface and an InstanceKlass.
3397     // If redefining Unsafe, walk all the itables looking for entries.
3398     if (ik->itable_length() > 0 && (_the_class_oop->is_interface()
3399         || _the_class_oop == SystemDictionary::misc_Unsafe_klass()
3400         || ik->is_subclass_of(_the_class_oop))) {
3401       // ik->itable() creates a wrapper object; rm cleans it up
3402       ResourceMark rm(_thread);
3403 
3404       ik->itable()->adjust_method_entries(the_class, &trace_name_printed);
3405     }
3406 
3407     // The constant pools in other classes (other_cp) can refer to
3408     // methods in the_class. We have to update method information in
3409     // other_cp's cache. If other_cp has a previous version, then we
3410     // have to repeat the process for each previous version. The
3411     // constant pool cache holds the Method*s for non-virtual
3412     // methods and for virtual, final methods.
3413     //
3414     // Special case: if the current class is the_class, then new_cp
3415     // has already been attached to the_class and old_cp has already
3416     // been added as a previous version. The new_cp doesn't have any
3417     // cached references to old methods so it doesn't need to be
3418     // updated. We can simply start with the previous version(s) in
3419     // that case.




3362            InstanceKlass::cast(_the_class_oop)->class_loader() != NULL;
3363     if (is_user_defined && ik->class_loader() == NULL) {
3364       return;
3365     }
3366 
3367     // Fix the vtable embedded in the_class and subclasses of the_class,
3368     // if one exists. We discard scratch_class and we don't keep an
3369     // InstanceKlass around to hold obsolete methods so we don't have
3370     // any other InstanceKlass embedded vtables to update. The vtable
3371     // holds the Method*s for virtual (but not final) methods.
3372     // Default methods, or concrete methods in interfaces are stored
3373     // in the vtable, so if an interface changes we need to check
3374     // adjust_method_entries() for every InstanceKlass, which will also
3375     // adjust the default method vtable indices.
3376     // We also need to adjust any default method entries that are
3377     // not yet in the vtable, because the vtable setup is in progress.
3378     // This must be done after we adjust the default_methods and
3379     // default_vtable_indices for methods already in the vtable.
3380     // If redefining Unsafe, walk all the vtables looking for entries.
3381     if (ik->vtable_length() > 0 && (_the_class_oop->is_interface()
3382         || _the_class_oop == SystemDictionary::internal_Unsafe_klass()
3383         || ik->is_subtype_of(_the_class_oop))) {
3384       // ik->vtable() creates a wrapper object; rm cleans it up
3385       ResourceMark rm(_thread);
3386 
3387       ik->vtable()->adjust_method_entries(the_class, &trace_name_printed);
3388       ik->adjust_default_methods(the_class, &trace_name_printed);
3389     }
3390 
3391     // If the current class has an itable and we are either redefining an
3392     // interface or if the current class is a subclass of the_class, then
3393     // we potentially have to fix the itable. If we are redefining an
3394     // interface, then we have to call adjust_method_entries() for
3395     // every InstanceKlass that has an itable since there isn't a
3396     // subclass relationship between an interface and an InstanceKlass.
3397     // If redefining Unsafe, walk all the itables looking for entries.
3398     if (ik->itable_length() > 0 && (_the_class_oop->is_interface()
3399         || _the_class_oop == SystemDictionary::internal_Unsafe_klass()
3400         || ik->is_subclass_of(_the_class_oop))) {
3401       // ik->itable() creates a wrapper object; rm cleans it up
3402       ResourceMark rm(_thread);
3403 
3404       ik->itable()->adjust_method_entries(the_class, &trace_name_printed);
3405     }
3406 
3407     // The constant pools in other classes (other_cp) can refer to
3408     // methods in the_class. We have to update method information in
3409     // other_cp's cache. If other_cp has a previous version, then we
3410     // have to repeat the process for each previous version. The
3411     // constant pool cache holds the Method*s for non-virtual
3412     // methods and for virtual, final methods.
3413     //
3414     // Special case: if the current class is the_class, then new_cp
3415     // has already been attached to the_class and old_cp has already
3416     // been added as a previous version. The new_cp doesn't have any
3417     // cached references to old methods so it doesn't need to be
3418     // updated. We can simply start with the previous version(s) in
3419     // that case.