Summary
Add a new lint option, missing-explicit-ctor
, to javac
to warn about reliance on a default constructor in a class that is part of a formal API.
Problem
While convenient for informal classes, default constructors in formal API classes will not have javadoc and may be unintended and unwanted.
Solution
Warn about reliance on a default constructor on classes where there is some likelihood of it being a problem, name public classes in a named package that has an unqualified export from its module. In addition, for nested classes, all the syntactically enclosing classes must be public too.
Specification
New text displayed as a key for javac
's -Xlint
:
missing-explicit-ctor Warn about missing explicit constructors in public classes in exported packages.
- csr of
-
JDK-8071961 Add javac lint warning when a default constructor is created
- Resolved
- relates to
-
JDK-8252348 Expand default constructor warning to cover more cases
- Closed