JDK-8250795 : Add javac lint warning when a default constructor is created
  • Type: CSR
  • Component: tools
  • Sub-Component: javac
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 16
  • Submitted: 2020-07-29
  • Updated: 2020-08-26
  • Resolved: 2020-08-18
Related Reports
CSR :  
Relates :  
Description
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.

Comments
Moving to Approved.
18-08-2020