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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 9
    • Fix Version/s: 10
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b34

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: