// base/Base.java
package base;
public class Base {
Base(String value) { }
}
// Derived.java
import base.Base;
public class Derived extends Base { }
javac 9.0.1 produces the following:
src/Derived.java:2: error: constructor Base in class Base cannot be applied to given types;
public class Derived extends Base { }
^
required: String
found: no arguments
reason: actual and formal argument lists differ in length
This is misleading because it implies that by adding a Derived constructor to call Base(String), that the error can be fixed; however, doing so results in a compiler.err.report.access error because the Base(String) constructor is not accessible:
src/Derived.java:4: error: Base(String) is not public in Base; cannot be accessed from outside package
super(value);
^
package base;
public class Base {
Base(String value) { }
}
// Derived.java
import base.Base;
public class Derived extends Base { }
javac 9.0.1 produces the following:
src/Derived.java:2: error: constructor Base in class Base cannot be applied to given types;
public class Derived extends Base { }
^
required: String
found: no arguments
reason: actual and formal argument lists differ in length
This is misleading because it implies that by adding a Derived constructor to call Base(String), that the error can be fixed; however, doing so results in a compiler.err.report.access error because the Base(String) constructor is not accessible:
src/Derived.java:4: error: Base(String) is not public in Base; cannot be accessed from outside package
super(value);
^
- relates to
-
JDK-8185451 Misleading 'cannot be accessed from outside package' diagnostic for inconsistent varargs override
- Resolved