< prev index next >

src/hotspot/share/oops/klassVtable.cpp

Print this page




 437   Symbol* signature = target_method()->signature();
 438 
 439   Klass* target_klass = target_method()->method_holder();
 440   if (target_klass == NULL) {
 441     target_klass = _klass;
 442   }
 443 
 444   Handle target_loader(THREAD, target_klass->class_loader());
 445 
 446   Symbol* target_classname = target_klass->name();
 447   for(int i = 0; i < super_vtable_len; i++) {
 448     Method* super_method;
 449     if (is_preinitialized_vtable()) {
 450       // If this is a shared class, the vtable is already in the final state (fully
 451       // initialized). Need to look at the super's vtable.
 452       klassVtable superVtable = super->vtable();
 453       super_method = superVtable.method_at(i);
 454     } else {
 455       super_method = method_at(i);
 456     }
 457     // Check if method name matches
 458     if (super_method->name() == name && super_method->signature() == signature) {



 459 
 460       // get super_klass for method_holder for the found method
 461       InstanceKlass* super_klass =  super_method->method_holder();
 462 
 463       // Whether the method is being overridden
 464       bool overrides = false;
 465 
 466       // private methods are also never overridden
 467       if (!super_method->is_private() &&
 468           (is_default
 469           || ((super_klass->is_override(super_method, target_loader, target_classname, THREAD))
 470           || ((klass->major_version() >= VTABLE_TRANSITIVE_OVERRIDE_VERSION)
 471           && ((super_klass = find_transitive_override(super_klass,
 472                              target_method, i, target_loader,
 473                              target_classname, THREAD))
 474                              != (InstanceKlass*)NULL)))))
 475         {
 476         // Package private methods always need a new entry to root their own
 477         // overriding. They may also override other methods.
 478         if (!target_method()->is_package_private()) {


 783   if (InstanceKlass::find_local_method(class_methods, name, signature,
 784               Klass::find_overpass, Klass::skip_static, Klass::skip_private) != NULL)
 785   {
 786     return false;
 787   }
 788 
 789   // Check local default methods
 790   if ((default_methods != NULL) &&
 791     (InstanceKlass::find_method(default_methods, name, signature) != NULL))
 792    {
 793      return false;
 794    }
 795 
 796   // Iterate on all superclasses, which should be InstanceKlasses.
 797   // Note that we explicitly look for overpasses at each level.
 798   // Overpasses may or may not exist for supers for pass 1,
 799   // they should have been created for pass 2 and later.
 800 
 801   for (const Klass* cursuper = super; cursuper != NULL; cursuper = cursuper->super())
 802   {
 803      if (InstanceKlass::cast(cursuper)->find_local_method(name, signature,
 804            Klass::find_overpass, Klass::skip_static, Klass::skip_private) != NULL) {




 805        return false;
 806      }
 807   }
 808 
 809   return true;
 810 }
 811 
 812 // Scans current_interface_methods for miranda methods that do not
 813 // already appear in new_mirandas, or default methods,  and are also not defined-and-non-private
 814 // in super (superclass).  These mirandas are added to all_mirandas if it is
 815 // not null; in addition, those that are not duplicates of miranda methods
 816 // inherited by super from its interfaces are added to new_mirandas.
 817 // Thus, new_mirandas will be the set of mirandas that this class introduces,
 818 // all_mirandas will be the set of all mirandas applicable to this class
 819 // including all defined in superclasses.
 820 void klassVtable::add_new_mirandas_to_lists(
 821     GrowableArray<Method*>* new_mirandas, GrowableArray<Method*>* all_mirandas,
 822     Array<Method*>* current_interface_methods, Array<Method*>* class_methods,
 823     Array<Method*>* default_methods, const Klass* super) {
 824 




 437   Symbol* signature = target_method()->signature();
 438 
 439   Klass* target_klass = target_method()->method_holder();
 440   if (target_klass == NULL) {
 441     target_klass = _klass;
 442   }
 443 
 444   Handle target_loader(THREAD, target_klass->class_loader());
 445 
 446   Symbol* target_classname = target_klass->name();
 447   for(int i = 0; i < super_vtable_len; i++) {
 448     Method* super_method;
 449     if (is_preinitialized_vtable()) {
 450       // If this is a shared class, the vtable is already in the final state (fully
 451       // initialized). Need to look at the super's vtable.
 452       klassVtable superVtable = super->vtable();
 453       super_method = superVtable.method_at(i);
 454     } else {
 455       super_method = method_at(i);
 456     }
 457     // Check if method name matches.  Ignore match if klass is an interface and the
 458     // matching method is a non-public java.lang.Object method.  (See JVMS 5.4.3.4)
 459     if (super_method->name() == name && super_method->signature() == signature &&
 460         (!_klass->is_interface() ||
 461          !SystemDictionary::is_nonpublic_Object_method(super_method))) {
 462 
 463       // get super_klass for method_holder for the found method
 464       InstanceKlass* super_klass =  super_method->method_holder();
 465 
 466       // Whether the method is being overridden
 467       bool overrides = false;
 468 
 469       // private methods are also never overridden
 470       if (!super_method->is_private() &&
 471           (is_default
 472           || ((super_klass->is_override(super_method, target_loader, target_classname, THREAD))
 473           || ((klass->major_version() >= VTABLE_TRANSITIVE_OVERRIDE_VERSION)
 474           && ((super_klass = find_transitive_override(super_klass,
 475                              target_method, i, target_loader,
 476                              target_classname, THREAD))
 477                              != (InstanceKlass*)NULL)))))
 478         {
 479         // Package private methods always need a new entry to root their own
 480         // overriding. They may also override other methods.
 481         if (!target_method()->is_package_private()) {


 786   if (InstanceKlass::find_local_method(class_methods, name, signature,
 787               Klass::find_overpass, Klass::skip_static, Klass::skip_private) != NULL)
 788   {
 789     return false;
 790   }
 791 
 792   // Check local default methods
 793   if ((default_methods != NULL) &&
 794     (InstanceKlass::find_method(default_methods, name, signature) != NULL))
 795    {
 796      return false;
 797    }
 798 
 799   // Iterate on all superclasses, which should be InstanceKlasses.
 800   // Note that we explicitly look for overpasses at each level.
 801   // Overpasses may or may not exist for supers for pass 1,
 802   // they should have been created for pass 2 and later.
 803 
 804   for (const Klass* cursuper = super; cursuper != NULL; cursuper = cursuper->super())
 805   {
 806      Method* found_mth = InstanceKlass::cast(cursuper)->find_local_method(name, signature,
 807            Klass::find_overpass, Klass::skip_static, Klass::skip_private);
 808      // Continue looking if found_mth is a non-public method in java.lang.Object
 809      // because such methods are skipped over during interface method resolution
 810      // and may 'mask' an actual miranda method.
 811      if (found_mth != NULL && !SystemDictionary::is_nonpublic_Object_method(found_mth)) {
 812        return false;
 813      }
 814   }
 815 
 816   return true;
 817 }
 818 
 819 // Scans current_interface_methods for miranda methods that do not
 820 // already appear in new_mirandas, or default methods,  and are also not defined-and-non-private
 821 // in super (superclass).  These mirandas are added to all_mirandas if it is
 822 // not null; in addition, those that are not duplicates of miranda methods
 823 // inherited by super from its interfaces are added to new_mirandas.
 824 // Thus, new_mirandas will be the set of mirandas that this class introduces,
 825 // all_mirandas will be the set of all mirandas applicable to this class
 826 // including all defined in superclasses.
 827 void klassVtable::add_new_mirandas_to_lists(
 828     GrowableArray<Method*>* new_mirandas, GrowableArray<Method*>* all_mirandas,
 829     Array<Method*>* current_interface_methods, Array<Method*>* class_methods,
 830     Array<Method*>* default_methods, const Klass* super) {
 831 


< prev index next >