Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8029674 (reflect) getMethods returns default methods that are not members of the class
  3. JDK-8177361

Release Note: Default methods affect the result of Class.getMethod and Class.getMethods

XMLWordPrintable

      The javadoc for the Class.getMethod and Class.getMethods refer to the definition of inheritance in the Java Language Specification. Java SE 8 changed these rules in order to support default methods and reduce the number of redundant methods inherited from superinterfaces (see JLS 8, 8.4.8).

      Class.getMethod and Class.getMethods were not updated with the 8 release to match the new inheritance definition (both may return non-inherited superinterface methods). Typically, the distinction is of no consequence; and for compatibility, it is preferred that the identity and number of returned methods match Java SE 7 as closely as possible. However, when the overriding method is a default method, it is important to filter out other overridden methods. As of 8u20, the implementation has been changed to perform this filtering step when the overrider is a default method.

            dlsmith Dan Smith
            mtrudeau Michel Trudeau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: