comparison src/share/vm/oops/klassVtable.cpp @ 5710:379f11bc04fc

8028438: static superclass method masks default methods Reviewed-by: hseigel, lfoltan, coleenp
author acorn
date Tue, 03 Dec 2013 11:13:14 -0800
parents 9d15b81d5d1b
children 5832cdaf89c6
comparison
equal deleted inserted replaced
30:89fc49f0ffe4 31:edb55ad8a6c4
663 return false; 663 return false;
664 } 664 }
665 665
666 // check if a method is a miranda method, given a class's methods table, 666 // check if a method is a miranda method, given a class's methods table,
667 // its default_method table and its super 667 // its default_method table and its super
668 // Miranda methods are calculated twice:
669 // first: before vtable size calculation: including abstract and default
670 // This is seen by default method creation
671 // Second: recalculated during vtable initialization: only abstract
672 // This is seen by link resolution and selection.
668 // "miranda" means not static, not defined by this class. 673 // "miranda" means not static, not defined by this class.
669 // private methods in interfaces do not belong in the miranda list. 674 // private methods in interfaces do not belong in the miranda list.
670 // the caller must make sure that the method belongs to an interface implemented by the class 675 // the caller must make sure that the method belongs to an interface implemented by the class
671 // Miranda methods only include public interface instance methods 676 // Miranda methods only include public interface instance methods
672 // Not private methods, not static methods, not default == concrete abstract 677 // Not private methods, not static methods, not default == concrete abstract
676 if (m->is_static() || m->is_private() || m->is_overpass()) { 681 if (m->is_static() || m->is_private() || m->is_overpass()) {
677 return false; 682 return false;
678 } 683 }
679 Symbol* name = m->name(); 684 Symbol* name = m->name();
680 Symbol* signature = m->signature(); 685 Symbol* signature = m->signature();
681 if (InstanceKlass::find_method(class_methods, name, signature) == NULL) { 686
687 if (InstanceKlass::find_instance_method(class_methods, name, signature) == NULL) {
682 // did not find it in the method table of the current class 688 // did not find it in the method table of the current class
683 if ((default_methods == NULL) || 689 if ((default_methods == NULL) ||
684 InstanceKlass::find_method(default_methods, name, signature) == NULL) { 690 InstanceKlass::find_method(default_methods, name, signature) == NULL) {
685 if (super == NULL) { 691 if (super == NULL) {
686 // super doesn't exist 692 // super doesn't exist
687 return true; 693 return true;
688 } 694 }
689 695
690 Method* mo = InstanceKlass::cast(super)->lookup_method(name, signature); 696 Method* mo = InstanceKlass::cast(super)->lookup_method(name, signature);
697 while (mo != NULL && mo->access_flags().is_static()
698 && mo->method_holder() != NULL
699 && mo->method_holder()->super() != NULL)
700 {
701 mo = mo->method_holder()->super()->uncached_lookup_method(name, signature);
702 }
691 if (mo == NULL || mo->access_flags().is_private() ) { 703 if (mo == NULL || mo->access_flags().is_private() ) {
692 // super class hierarchy does not implement it or protection is different 704 // super class hierarchy does not implement it or protection is different
693 return true; 705 return true;
694 } 706 }
695 } 707 }