JDK-8252348 : Expand default constructor warning to cover more cases
  • Type: CSR
  • Component: tools
  • Sub-Component: javac
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 16
  • Submitted: 2020-08-25
  • Updated: 2020-08-27
  • Resolved: 2020-08-26
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Expand the lint warning added under JDK-8071961 to cover `protected` classes as well as `public` ones.

Problem
-------

Besides `public` classes having default constructors exposed accidentally, a `protected` class can have its default constructors exposed too as part of the full API of a package.

Solution
--------

Expand the lint warning to cover `protected` classes with the other conditions staying the same. In detail, a warning is issued for `public` or `protected` classes in a named package that has an unqualified export from its module where, for nested classes, all the syntactically enclosing classes must are either `public` or `protected`.

Specification
-------------

     javac.opt.Xlint.desc.missing-explicit-ctor=\
    -    Warn about missing explicit constructors in public classes in exported packages.
    +    Warn about missing explicit constructors in public and protected classes in exported packages.


Comments
Moving to Approved.
26-08-2020

Adding [~abuckley] as a reviewer per https://mail.openjdk.java.net/pipermail/compiler-dev/2020-August/014856.html
26-08-2020