changeset 8053:cf0049037deb

8010427: Refine Method.isDefault implementation Reviewed-by: acorn, dlsmith
author darcy
date Wed, 20 Mar 2013 15:21:14 -0700
parents ccd9f53377c4
children 3c1a4966d901
files src/share/classes/java/lang/reflect/Method.java
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/reflect/Method.java	Wed Mar 20 09:50:07 2013 -0700
+++ b/src/share/classes/java/lang/reflect/Method.java	Wed Mar 20 15:21:14 2013 -0700
@@ -522,16 +522,19 @@
      * Returns {@code true} if this method is a default
      * method; returns {@code false} otherwise.
      *
-     * A default method is a non-abstract method, that is, a method
-     * with a body, declared in an interface type.
+     * A default method is a public non-abstract instance method, that
+     * is, a non-static method with a body, declared in an interface
+     * type.
      *
      * @return true if and only if this method is a default
      * method as defined by the Java Language Specification.
      * @since 1.8
      */
     public boolean isDefault() {
-        return (getModifiers() & Modifier.ABSTRACT) == 0 &&
-            getDeclaringClass().isInterface();
+        // Default methods are public non-abstract instance methods
+        // declared in an interface.
+        return ((getModifiers() & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) ==
+                Modifier.PUBLIC) && getDeclaringClass().isInterface();
     }
 
     // NOTE that there is no synchronization used here. It is correct