Requires, Exports, and Provides
Paul Benedict
pbenedict at apache.org
Mon Nov 30 18:57:40 UTC 2015
Tim, I hope the EG will be able to discuss the comments here contained and
provide an official response. It's my understanding the EG hasn't met in a
very long time.
Points I want to clarify:
a) The additional syntax is not to solve technical ambiguity; just enhance
instant readability. FQN modules, packages, and classes are all possible in
the file.
b) Replacing "with" with "for" is to reuse an existing keyword (and not
introduce a new one even if it is context-sensitive).
c) As for the packages and modules being named the same, I have already
advocated the use of underscores, which would make them legal Java
identifiers in the existing language spec. The current syntax is clearly
being driven out of The State of the Module System: "Module names, like
package names, must not conflict. The recommended way to name a module is
to use the reverse-domain-name pattern that has long been recommended for
naming packages. The name of a module will, therefore, often be a prefix of
the names of its exported packages, but this relationship is not mandatory."
Cheers,
Paul
On Fri, Nov 27, 2015 at 10:49 AM, Tim Ellison <Tim_Ellison at uk.ibm.com>
wrote:
> ... and yet in type declarations we use "extends" and "implements" ;-)
>
> I agree that readability, and thereby comprehension, is not enhanced by
> naming modules in the same way we name packages.
>
> Tim
>
>
>
> Paul Benedict <pbenedict at apache.org> wrote on 27/11/2015 14:01:57:
> > You made an interesting analogy regarding the "import" syntax. I was
> > thinking about it... If you really want the module syntax to fit
> > with current syntax, the keywords should be in the imperative form:
> > require, export, provide. The ending "s" should be dropped.
> > Cheers,
> > Paul
> > On Nov 27, 2015 4:22 AM, "Tim Ellison" <Tim_Ellison at uk.ibm.com> wrote:
> > Hello Paul,
> >
> > Being explicit would help if there were any ambiguity about the
> > declaration, and I'm not convinced that adding the additional syntax
> > would be helpful here.
> >
> > In particular, the current pattern, e.g. "exports java.sql;" fits
> > with the existing syntax for an import statement. That is, we write
> >
> > import java.sql.Timestamp;
> > or
> > import java.sql.*;
> >
> > and not "import class" and "import package"
> >
> > As for the service provider, I guess it is a matter of taste, but
> > I'm comfortable that the service interface is more prominent than
> > the implementation type.
> >
> > Regards,
> > Tim
> >
> >
> > Paul Benedict <pbenedict at apache.org> wrote on 25/11/2015 22:48:42:
> > > Dear EG members, are you still refining syntax? If so, I would like
> you to
> > > consider making the keywords a bit more explicit regarding "requires",
> > > "exports", and "provides/uses" by adding "module", "package", and
> "class"
> > > respectively.
> > >
> > > Personally, I find the explicitness to be much more instantly readable.
> > > WDYT?
> > >
> > > module java.sql {
> > > requires module java.logging;
> > > requires module java.xml;
> > > exports package java.sql;
> > > exports package javax.sql;
> > > exports package javax.transaction.xa;
> > > provides class java.sql.Driver with com.mysql.jdbc.Driver;
> > > }
> > >
> > > module java.base {
> > > ...
> > > exports package to
> > > module java.corba,
> > > module java.logging,
> > > module java.sql,
> > > module java.sql.rowset,
> > > module jdk.scripting.nashorn;
> > > }
> > >
> > > I also think you could replace "with" with "for" if you flip the
> ordering:
> > > provides class com.mysql.jdbc.Driver for java.sql.Driver;
> > >
> > > Cheers,
> > > Paul
> > >
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
>
>
More information about the jpms-spec-comments
mailing list