JDK-8216527 : Provided supported mechanims to create a ModuleElement for an unnamed module
  • Type: CSR
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 13
  • Submitted: 2019-01-10
  • Updated: 2019-01-11
  • Resolved: 2019-01-11
Related Reports
CSR :  
Description
Summary
-------

Add a supported mechanism to create a module element for an unnamed module.

Problem
-------

The `javax.lang.model` API does not include a specified and supported way to create object representing an unnamed module.

Solution
--------

Augment the specification of `Elements.getModuleElement` to include this functionality. The wording is analogous to how unnamed packages are described for `Elements.getPackageElement`

Specification
-------------

         /**
          * Returns a module element given its fully qualified name.
          *
    -     * If the named module cannot be found, {@code null} is
    +     * If the requested module cannot be found, {@code null} is
          * returned. One situation where a module cannot be found is if
          * the environment does not include modules, such as an annotation
          * processing environment configured for a {@linkplain
          * javax.annotation.processing.ProcessingEnvironment#getSourceVersion
          * source version} without modules.
          *
          * @implSpec The default implementation of this method returns
          * {@code null}.
          *
    -     * @param name  the name
    +     * @param name  the name, or an empty string for an unnamed module
          * @return the named module element, or {@code null} if it cannot be found
          * @see #getAllModuleElements
          * @since 9
          * @spec JPMS
          */
      default ModuleElement getModuleElement(CharSequence name)

Note the wording is changed from "named module" to "requested module" since requesting an *unnamed* module is now supported.
Comments
Moving to Approved.
11-01-2019