JDK-8216501 : javax.lang.model should provide utility predicates for ModuleElements
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2019-01-10
  • Updated: 2021-08-04
  • Resolved: 2021-08-04
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
It should be possible to determine if a module element is for an unnamed module, or for an automatic module.  This information is available within the java implementation, but should be exposed to clients via the public API.

One possible solution that is in line with similar existing methods would be to provide the following methods:

boolean Elements.isUnnamedModule(ModuleElement)
boolean Elements.isAutomaticModule(ModuleElement)
Comments
The ModuleElement interface includes an isUnnamed() method. Closing this bug as a duplicate of JDK-8264865.
04-08-2021

Note: Elements.isAutoMaticModule was added in JDK-8264865.
03-08-2021

Hmmm, good question; ModuleSymbol in javac contains `Name version` which is probably the equivalent of the runtime rawVersion. While it might be worth exposing the version, I'm not sure how far we want to go in mimicking the unparsed and parsed versions.
11-01-2019

Besides isAutomatic, is there any other functionality present on java.lang.module.ModuleDescriptor that should be replicated for module elements?
10-01-2019

Note that for the functionality of unnamed checking, ModuleElement already has an isUnnamed method: https://download.java.net/java/early_access/jdk12/docs/api/java.compiler/javax/lang/model/element/ModuleElement.html#isUnnamed()
10-01-2019

Also related is the ability to create unnamed modules through explicitly supported API, JDK-8208371. .
10-01-2019