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

7.4.2: Tighten the compilation units in an unnamed package

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 12
    • 11
    • specification

      (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).

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

              Created:
              Updated:
              Resolved: