src/share/vm/oops/klassVtable.cpp

changeset 9756
2be326848943
parent 9041
95a08233f46c
parent 9743
657162a310c4
child 9806
758c07667682
equal deleted inserted replaced
9707:b87dc103bf45 9756:2be326848943
661 Symbol* signature = target_method()->signature(); 661 Symbol* signature = target_method()->signature();
662 Klass* k = super; 662 Klass* k = super;
663 Method* super_method = NULL; 663 Method* super_method = NULL;
664 InstanceKlass *holder = NULL; 664 InstanceKlass *holder = NULL;
665 Method* recheck_method = NULL; 665 Method* recheck_method = NULL;
666 bool found_pkg_prvt_method = false;
666 while (k != NULL) { 667 while (k != NULL) {
667 // lookup through the hierarchy for a method with matching name and sign. 668 // lookup through the hierarchy for a method with matching name and sign.
668 super_method = InstanceKlass::cast(k)->lookup_method(name, signature); 669 super_method = InstanceKlass::cast(k)->lookup_method(name, signature);
669 if (super_method == NULL) { 670 if (super_method == NULL) {
670 break; // we still have to search for a matching miranda method 671 break; // we still have to search for a matching miranda method
682 (!super_method->is_private())) { 683 (!super_method->is_private())) {
683 if (superk->is_override(super_method, classloader, classname, THREAD)) { 684 if (superk->is_override(super_method, classloader, classname, THREAD)) {
684 return false; 685 return false;
685 // else keep looking for transitive overrides 686 // else keep looking for transitive overrides
686 } 687 }
688 // If we get here then one of the super classes has a package private method
689 // that will not get overridden because it is in a different package. But,
690 // that package private method does "override" any matching methods in super
691 // interfaces, so there will be no miranda vtable entry created. So, set flag
692 // to TRUE for use below, in case there are no methods in super classes that
693 // this target method overrides.
694 assert(super_method->is_package_private(), "super_method must be package private");
695 assert(!superk->is_same_class_package(classloader(), classname),
696 "Must be different packages");
697 found_pkg_prvt_method = true;
687 } 698 }
688 699
689 // Start with lookup result and continue to search up 700 // Start with lookup result and continue to search up
690 k = superk->super(); // haven't found an override match yet; continue to look 701 k = superk->super(); // haven't found an override match yet; continue to look
702 }
703
704 // If found_pkg_prvt_method is set, then the ONLY matching method in the
705 // superclasses is package private in another package. That matching method will
706 // prevent a miranda vtable entry from being created. Because the target method can not
707 // override the package private method in another package, then it needs to be the root
708 // for its own vtable entry.
709 if (found_pkg_prvt_method) {
710 return true;
691 } 711 }
692 712
693 // if the target method is public or protected it may have a matching 713 // if the target method is public or protected it may have a matching
694 // miranda method in the super, whose entry it should re-use. 714 // miranda method in the super, whose entry it should re-use.
695 // Actually, to handle cases that javac would not generate, we need 715 // Actually, to handle cases that javac would not generate, we need
696 // this check for all access permissions. 716 // this check for all access permissions.
697 InstanceKlass *sk = InstanceKlass::cast(super); 717 InstanceKlass *sk = InstanceKlass::cast(super);
698 if (sk->has_miranda_methods()) { 718 if (sk->has_miranda_methods()) {
699 if (sk->lookup_method_in_all_interfaces(name, signature, Klass::find_defaults) != NULL) { 719 if (sk->lookup_method_in_all_interfaces(name, signature, Klass::find_defaults) != NULL) {
700 return false; // found a matching miranda; we do not need a new entry 720 return false; // found a matching miranda; we do not need a new entry
701 } 721 }
702 } 722 }
703 return true; // found no match; we need a new entry 723 return true; // found no match; we need a new entry
704 } 724 }
705 725

mercurial