Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8009411

(reflect) Class.getMethods should not include static methods from interfaces

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 8
    • core-libs
    • 8
    • b115
    • generic
    • generic
    • Verified

      The javadoc for 'Class.getMethods' references the JLS concept of membership, so inheritance should be consistent with JLS. In the language model, static methods are inherited from a superclass, but not from superinterfaces.

      public class InheritStatic {

       static class A {
         public void m() {}
         public static void n() {}
       }

       interface I {
         public void o();
         public static void p() {} // comment out to test with JDK 7
       }

       static abstract class B extends A implements I {}

       public static void main(String... args) {
         Object[] ms = B.class.getMethods();
         for (Object m : ms) System.out.println(m);
       }

      }

      Expected: A.n is printed, I.p is not.

      Actual: Both A.n and Ip. are printed.

            jfranck Joel Borggrén-Franck (Inactive)
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: