[External] : Re: ModuleElement doesn't work with generated provides classes?

Josiah Noel josiahnoel at gmail.com
Tue Sep 19 23:04:57 UTC 2023


I see that the issue has moved to a resolved state, but I still have some
doubts. The original question was indeed about retrieving the
provides statements, and as the issue explains this is currently not
possible. I accept this.

 My main concern now is that compilation fails when getDirectives is called
for a project's ModuleElement. As expected I can receive everything except
the provides statements for the generated class, and yet compilation still
fails. Can anything be done to resolve this?

On Fri, Sep 1, 2023 at 8:00 AM Josiah Noel <josiahnoel at gmail.com> wrote:

> Or else if it's truly impossible to prevent the compilation error, a
> warning should be added to getDirectives so that people know it has a
> chance of breaking someone else's build in certain situations. I maintain a
> couple of processors that generate service implementations in the last
> round, so if people use one of them with another processor that uses
> getDirectives it will break their build with this cryptic(to them) error.
>
> On Mon, Aug 28, 2023 at 2:48 PM Josiah Noel <josiahnoel at gmail.com> wrote:
>
>> I see it has been partially fixed in a later version, and that the
>> problem only occurs if the service impl is generated in the last round. I
>> can tolerate not being able to explicitly see the `provides` statements,
>> but it's still a problem if merely calling `ModuleElement.getDirectives`
>> causes compilation to fail if services are generated in the last round. Is
>> there a way that we can make the behavior the same except not failing
>> compilation? (Currently I can see the requires just fine but the
>> compilation is doomed to fail)
>>
>> On Mon, Aug 28, 2023 at 2:05 PM Jonathan Gibbons <
>> jonathan.gibbons at oracle.com> wrote:
>>
>>> https://bugs.openjdk.org/browse/JDK-8315125
>>>
>>> -- Jon
>>> On 8/28/23 8:50 AM, Jonathan Gibbons wrote:
>>>
>>> I'll file a JBS issue to track this further.
>>>
>>> -- Jon
>>>
>>>
>>> On 8/28/23 8:35 AM, Josiah Noel wrote:
>>>
>>> Just tried explicitly adding a default constructor, but I still receive
>>> the same error.
>>>
>>> On Mon, Aug 28, 2023 at 11:29 AM Jonathan Gibbons <
>>> jonathan.gibbons at oracle.com> wrote:
>>>
>>>> The following error message seems relevant:
>>>>
>>>> /M:/Dev/module-directive-bug/blackbox-test-module/src/main/java/module-info.java:[6,41] the service implementation does not have
>>>> a default constructor: io.avaje.modules.example.GeneratedProvider
>>>>
>>>> -- Jon
>>>>
>>>>
>>>> On 8/26/23 1:04 PM, Josiah Noel wrote:
>>>>
>>>> As requested, I have created a simple example to replicate this issue. SentryMan/module-directive-bug:
>>>> showcase annotation processing bug (github.com)
>>>> <https://urldefense.com/v3/__https://github.com/SentryMan/module-directive-bug/tree/master__;!!ACWV5N9M2RV99hQ!O3CMUWVsFHaaU7b9D1x_-4ByzBUrMMF0KeTPmtdnqOC1hRhhZCBO0dODJwf1rZsapQpTYmYktzo5W_0TwANTUZuu$>
>>>>
>>>> On Fri, Aug 25, 2023 at 9:00 PM Josiah Noel <josiahnoel at gmail.com>
>>>> wrote:
>>>>
>>>>> Say I got this module
>>>>>
>>>>> ```
>>>>>
>>>>> module nima.example {
>>>>>
>>>>> requires io.avaje.http.client;
>>>>>
>>>>> requires io.avaje.http.api;
>>>>>
>>>>> provides io.avaje.http.client.HttpClient.GeneratedComponent with
>>>>>
>>>>> com.jojo.helidon.api.client.httpclient.GeneratedHttpComponent;
>>>>>
>>>>> }
>>>>> ```
>>>>> and I generate com.jojo.helidon.api.client.httpclient.
>>>>> GeneratedHttpComponent in the last round of processing. When I get
>>>>> the module element during normal processing and so much as call
>>>>> `ModuleElement#getDirectives` and do nothing else, the processor will
>>>>> correctly generate, but compilation will still fail.(if I take out the
>>>>> module-info from the project it works though) I'm pretty sure it might have
>>>>> to do with the fact that GeneratedHttpComponent is created in the
>>>>> last round. Even so, not sure why it fails the compilation.
>>>>>
>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20230919/3b7a2b54/attachment-0001.htm>


More information about the compiler-dev mailing list