diff 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
line wrap: on
line diff
--- a/src/share/vm/oops/klassVtable.cpp	Tue Dec 03 08:36:15 2013 -0800
+++ b/src/share/vm/oops/klassVtable.cpp	Tue Dec 03 11:13:14 2013 -0800
@@ -665,6 +665,11 @@
 
 // check if a method is a miranda method, given a class's methods table,
 // its default_method table  and its super
+// Miranda methods are calculated twice:
+// first: before vtable size calculation: including abstract and default
+// This is seen by default method creation
+// Second: recalculated during vtable initialization: only abstract
+// This is seen by link resolution and selection.
 // "miranda" means not static, not defined by this class.
 // private methods in interfaces do not belong in the miranda list.
 // the caller must make sure that the method belongs to an interface implemented by the class
@@ -678,7 +683,8 @@
   }
   Symbol* name = m->name();
   Symbol* signature = m->signature();
-  if (InstanceKlass::find_method(class_methods, name, signature) == NULL) {
+
+  if (InstanceKlass::find_instance_method(class_methods, name, signature) == NULL) {
     // did not find it in the method table of the current class
     if ((default_methods == NULL) ||
         InstanceKlass::find_method(default_methods, name, signature) == NULL) {
@@ -688,6 +694,12 @@
       }
 
       Method* mo = InstanceKlass::cast(super)->lookup_method(name, signature);
+      while (mo != NULL && mo->access_flags().is_static()
+             && mo->method_holder() != NULL
+             && mo->method_holder()->super() != NULL)
+      {
+         mo = mo->method_holder()->super()->uncached_lookup_method(name, signature);
+      }
       if (mo == NULL || mo->access_flags().is_private() ) {
         // super class hierarchy does not implement it or protection is different
         return true;