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

Javac does not allow private interface methods to be declared final

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 9
    • None
    • tools
    • None
    • generic
    • generic

      This program:

      // --
      interface IfaceWithPrivateFinalMethod {
          private final void privateFinalMethod() {}
      }

      triggers the error:

      X.java:2: error: modifier final not allowed here
          private final void privateFinalMethod() {}
                             ^
      1 error

      It would seem since private methods are not inherited, they are final anyway and the compiler should allow the combination of private and final to modify an interface method.

            sadayapalam Srikanth Adayapalam (Inactive)
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: