Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8252348

Expand default constructor warning to cover more cases

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 16
    • tools
    • None
    • behavioral
    • minimal
    • Protected classes occur much less often than public ones, minimal addition in practice to the number of warnings that would be issued.
    • Other
    • JDK

      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.

            darcy Joe Darcy
            darcy Joe Darcy
            Alex Buckley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: