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
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
- relates to
-
JDK-8191896 confusing applicability error
- Open