-
Bug
-
Resolution: Fixed
-
P4
-
11
(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).
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).