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

private access modifier apparently ignored in interfaces

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1
    • CPU:
      sparc
    • OS:
      windows
    • Verification:
      Not verified

      Description

      class Intmad implements Foo, Bar {
        public static void main(String[] argv) {
          System.out.println(quux);
        }
      }

      interface Foo {
        private int quux = 3;
        int quax = quux+1;
      }

      interface Bar {
        double quux = 7.3;
      }

      gives this compile-time error:

      Intmad.java:3: Reference to quux is ambiguous. It is defined in interface Bar and interface Foo.
          System.out.println(quux);
                             ^
      1 error

      Apparently declared a field "private" in an interface doesn't cut any ice?
      But then why doesn't the compiler complain about the "private" modifier?
      What are the rules here?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fyellinsunw Frank Yellin (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: