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

javac reports "cannot override" messages instead of "cannot hide" messages for static methods

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • tools
    • b93
    • generic
    • generic
    • Verified

      File: A.java

      class A {
         static void func() { }
      }

      File: B.java

      class B extends A {
         static int func() { return 0; }
      }

      B.java:2: error: func() in B cannot override func() in A
         static int func() { return 0; }
                    ^
        return type int is not compatible with void
      1 error

      The error message should be "func() in B cannot hide func() in A..."

      Similarly when A.java is changed to be

      class A {
         static final void func() { }
      }

      the error reported is

      B.java:2: error: func() in B cannot override func() in A
         static int func() { return 0; }
                    ^
        overridden method is static,final
      1 error

      Again, word "override" should have been "hide" and "overridden" should have been "hidden"

            sdama Srinivas Dama (Inactive)
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: