Proposal: #ModuleNameCharacters

mark.reinhold at oracle.com mark.reinhold at oracle.com
Tue Nov 22 16:49:35 UTC 2016


Issue summary
-------------

  #ModuleNameCharacters --- Module names are presently constrained to
  be Java identifiers.  Some existing module systems allow additional
  characters in module names, such as hyphens and slashes.  Should this
  restriction be lifted or, perhaps, should it somehow be made
  layer-specific? [1]

Proposal
--------

Make no changes here.

Modules are a new construct of the Java programming language in the
present design.  In the source language they are hence identified by
qualified names [2] in the same manner as the existing structural
constructs, i.e., packages and classes.  As such these names do allow
some unusual characters, though not hyphens or slashes [3].

Module names in compiled module-declaration class files are recorded in
`CONSTANT_Utf8_info` structures, and thus have fewer constraints.  They
replace periods (`'.'`) with forward slashes (`'/'`), and disallow
periods, semicolons (`';'`), and left square brackets (`'['`) [4].  The
`ModuleDescriptor` API can read class files that contain module names not
expressible in the source language, though it cannot be used to construct
instances with such names.  Artifacts that define modules with such names
will be processed normally when placed on the module path.

The present design is, then, consistent with the existing treatment of
qualified names in the language, in class files, and in the Java SE API.

A different module system with a more-flexible naming scheme can easily
refer to JPMS modules, per the agreed interoperation requirement [5].
The requirements do not mandate bidirectional interoperation, which for
this issue would mean that JPMS modules must be able to refer to non-JPMS
modules with non-JPMS names.  To support that would add significant
complexity to this specification and its implementations.


[1] http://openjdk.java.net/projects/jigsaw/spec/issues/#ModuleNameCharacters
[2] http://docs.oracle.com/javase/specs/jls/se8/html/jls-6.html#jls-6.2
[3] http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.8
[4] http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.2.1
[5] http://openjdk.java.net/projects/jigsaw/spec/reqs/#interoperation


More information about the jpms-spec-experts mailing list