Misleading 'cannot be accessed from outside package' diagnostic for inconsistent varargs override

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 10
    • Affects Version/s: 8, 9
    • Component/s: tools
    • None
    • b34

      javac reports a 'cannot be accessed from outside package' diagnostic for the following program, which is misleading because A.f is declared and accessed in the same package.

      Note that the program contains an inconsistent varargs override: B.f should be `f(int...)`, not `f(int[])`.

      === T.java
      package test;
      class A {
        void f(int... x) {}
      }
      class B extends A {
        @Override void f(int[] x) {}
      }
      class T {
        {
          new B().f(1);
        }
      }
      ===

      $ javac -fullversion T.java
      javac full version "9+179"
      T.java:10: error: f(int...) is not public in A; cannot be accessed from outside package
          new B().f(1);
                 ^
      1 error

            Assignee:
            Vicente Arturo Romero Zaldivar
            Reporter:
            Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: