Ever thought of a ModuleElement Query function?

Jonathan Gibbons jonathan.gibbons at oracle.com
Tue Sep 12 15:13:46 UTC 2023


To find whether a project's ModuleElement contains a certain dependency, 
you can (recursively) examine the directives (in particular, the 
RequiresDirective) for the module(s).

https://docs.oracle.com/en/java/javase/20/docs/api/java.compiler/javax/lang/model/element/ModuleElement.html#getDirectives()

-- Jon


On 9/11/23 9:51 PM, Josiah Noel wrote:
>  Hello there,
>
> I think it would be nice if a sort of query method was added to 
> ModuleElement such that one can see if a certain module is on its graph.
>
> I want to add functionality to my annotation processor that should 
> check whether a project's ModuleElement contains a certain dependency. 
> Currently, I'm thinking I'll need to recursively iterate over the 
> directives to search the module path. (which naturally gets much 
> slower the more modules are involved)
>
> -- 
> Cheers, Josiah.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20230912/233e834b/attachment-0001.htm>


More information about the compiler-dev mailing list