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

Add javac lint warning when a default constructor is created

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 16
    • tools
    • None
    • behavioral
    • minimal
    • New warning.
    • add/remove/modify command line option
    • JDK

    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.

      Attachments

        Issue Links

          Activity

            People

              darcy Joe Darcy
              darcy Joe Darcy
              Jonathan Gibbons
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: