ModuleElement doesn't work with generated provides classes?

Joseph D. Darcy joe.darcy at oracle.com
Sat Aug 26 00:07:46 UTC 2023


Another relevant data point is if the module information could be 
retrieved from a module-info _source file_ but not a class file.

-Joe

On 8/25/2023 4:46 PM, Jonathan Gibbons wrote:
>
> If I understand you correctly, it seems that this ought to work. But 
> perception does not always match reality. It would help to have a toy 
> test case.
>
> -- Jon
>
> On 8/25/23 4:41 PM, Josiah Noel wrote:
>> I mean reading an existing module-info via ModuleElement, not 
>> creating a new one. The module-info I'm trying to read has generated 
>> classes in a provided clause.
>>
>> On Fri, Aug 25, 2023, 7:15 PM Joseph D. Darcy <joe.darcy at oracle.com> 
>> wrote:
>>
>>     Hello,
>>
>>     From your description, I'm not entirely clear of the compilation
>>     context you're working in. Note that by design the annotation
>>     processing API does not support the creation of module-info files
>>     via the Filer.
>>
>>     Cheers,
>>
>>     -Joe
>>
>>     On 8/25/2023 3:25 PM, Josiah Noel wrote:
>>>     I was able to work around it by using Filer to directly load the
>>>     module-info.java file as a string and parse it.
>>>
>>>     On Fri, Aug 25, 2023 at 1:04 AM Josiah Noel
>>>     <josiahnoel at gmail.com> wrote:
>>>
>>>         Hello there,
>>>
>>>         I'm adding functionality to my annotation processor to check
>>>         whether a generated class is registered on a
>>>         module-info.java. When I try to use
>>>         `ModuleElement#getDirectives`, I get the `requires`
>>>         statements, but I cannot get the `provides` statements I've
>>>         written.
>>>
>>>         Is it possible to get this to work? Or does the fact that
>>>         the classes are generated totally prevent me from getting
>>>         the provides statements?
>>>
>>>         -- 
>>>         Cheers, Josiah.
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20230825/6a921f20/attachment.htm>


More information about the compiler-dev mailing list