diff src/share/vm/classfile/defaultMethods.cpp @ 21829:02e2c04a3289

8065366: Better private method resolution Reviewed-by: hseigel, lfoltan, coleenp, ahgross
author acorn
date Thu, 18 Dec 2014 17:59:15 -0800
parents 78bbf4d43a14
children 12dcf5ba8b34
line wrap: on
line diff
--- a/src/share/vm/classfile/defaultMethods.cpp	Wed Dec 17 09:10:57 2014 -0800
+++ b/src/share/vm/classfile/defaultMethods.cpp	Thu Dec 18 17:59:15 2014 -0800
@@ -731,10 +731,12 @@
     Method* m = iklass->find_method(_method_name, _method_signature);
     // private interface methods are not candidates for default methods
     // invokespecial to private interface methods doesn't use default method logic
+    // private class methods are not candidates for default methods,
+    // private methods do not override default methods, so need to perform
+    // default method inheritance without including private methods
     // The overpasses are your supertypes' errors, we do not include them
     // future: take access controls into account for superclass methods
-    if (m != NULL && !m->is_static() && !m->is_overpass() &&
-         (!iklass->is_interface() || m->is_public())) {
+    if (m != NULL && !m->is_static() && !m->is_overpass() && !m->is_private()) {
       if (_family == NULL) {
         _family = new StatefulMethodFamily();
       }
@@ -745,6 +747,9 @@
       } else {
         // This is the rule that methods in classes "win" (bad word) over
         // methods in interfaces. This works because of single inheritance
+        // private methods in classes do not "win", they will be found
+        // first on searching, but overriding for invokevirtual needs
+        // to find default method candidates for the same signature
         _family->set_target_if_empty(m);
       }
     }