Java Platform Module System
alex.buckley at oracle.com
Tue May 2 22:27:56 UTC 2017
On 5/2/2017 5:13 AM, Stephan Herrmann wrote:
> Thanks, Alex, for promising improvements in various places of the spec.
Re: Multiple packages with the same name can be "visible" (helpful
terminology for program analysis) but exactly one of these packages must
be identified as the meaning of the name. First, let's define what we want:
7.4.3 Package Observability and Visibility
A package is _uniquely visible_ to a module M if and only if either (i)
an ordinary compilation unit associated with M contains a declaration of
the package, and M does not read any other module that exports the
package to M; or (ii) no ordinary compilation unit associated with M
contains a declaration of the package, and M reads exactly one other
module that exports the package to M.
Then we can pick the "right" package to go with the name:
220.127.116.11 Simple Package Names
If a package name consists of a single Identifier, then the identifier
must occur in the scope of exactly one declaration of a top level
package with this name (§6.3), and that package must be uniquely visible
to the current module (§7.4.3), or a compile-time error occurs. The
meaning of the package name is that package.
18.104.22.168 Qualified Package Names
If a package name is of the form Q.Id, then Q must also be a package
name. The package name Q.Id names a package that is the member named Id
within the package named by Q. If Q.Id does not name a package that is
uniquely visible to the current module (§7.4.3), then a compile-time
(Note that 22.214.171.124 did not, and does not, recurse into 126.96.36.199 when the
Q in the qualified name Q.Id is simple. 188.8.131.52 relies on scope, which
means it applies only when someone has a declaration of a top level
package, but plainly 184.108.40.206 has always been able to give meaning to the
name P.Q based on a declaration of 'package P.Q;' -- no-one needed to
declare a top level 'package P;'. The 220.127.116.11 phrase "Q must also be a
package name" in JLS8 was a trailer for the phrase about Q being an
observable package, and in JLS9 is a trailer for the phrase about Q.Id
being a uniquely visible package.)
> I recall several threads on this list ending in you saying "still being
> clarified" . Are those issues settled by now and just need to be
> penned down? Otherwise it would be very helpful just to see the list of
> open questions, so we don't bang our heads against walls that are still
> subject to change (I'm not speaking about the general "Issue Summary",
> but s.t. more focused on JLS and its dependencies in JPMS spec).
> Looking forward to an updated spec version, allowing us to double check
> if those changes raise any follow-up questions,
This was about multiple packages with the name P being visible at once.
So that's covered by the "uniquely visible" invocation in package names.
The open question there was about multiple modules, directly required by
a root module, containing the same package, but without any exports that
would cause any module to see a split package. This module graph is
legal, so it will resolve in JPMS; the JLS defers to that.
javac gives a lint warning (on-by-default, suppressible) if the modules
being compiled cannot be mapped to the boot layer.
More information about the jigsaw-dev