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

Redundant warning for static interface method invoked via expression

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P5 P5
    • tbd
    • 8
    • tools
    • None

      The following produces an error and a warning. The warning is redundant.

      public class StaticInvoke {

        interface I {
          static void m() { m(); } // ok
        }
        
        void test(I arg) {
          I.m(); // ok
          arg.m(); // error
        }
      }

      StaticInvoke.java:9: warning: [static] static method should be qualified by type name, I, instead of by an expression
          arg.m(); // error
             ^
      StaticInvoke.java:9: error: illegal static interface method call
          arg.m(); // error
               ^
        the receiver expression should be replaced with the type qualifier 'I'
      1 error
      1 warning

            vromero Vicente Arturo Romero Zaldivar
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: