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

7.4.2: Tighten the compilation units in an unnamed package

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 11
    • Fix Version/s: 12
    • Component/s: specification
    • Labels:

      Description

      (See http://mail.openjdk.java.net/pipermail/compiler-dev/2018-December/012705.html)

      The longstanding rule that "An ordinary compilation unit that has no package declaration is part of an unnamed package." should be tightened: "An ordinary compilation unit that has no package declaration, ***but has at least one other kind of declaration,*** is part of an unnamed package."

      This leaves open the question of an ordinary compilation unit with no package declaration AND no import or type declarations. Such an ordinary compilation unit is allowed by the grammar but has no semantic meaning, so the question of package membership is moot. In practice, compilers ignore such an ordinary compilation unit when it is "detected" in an empty source file (i.e. a zero length file, or a file containing just whitespace and comments).

        Attachments

          Activity

            People

            • Assignee:
              abuckley Alex Buckley
              Reporter:
              abuckley Alex Buckley
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: