Re: Default for annotation members with type class

Christopher Smith <[email protected]> Tue, 15 Apr 2025 19:40:27 -0500
Newsgroups gmane.comp.lang.groovy.user
Message-ID <CAG+8NVra8QRYXOMOYLQM2CT_XHcXqeji9bRPpOV+Y6LHqCEzQA@mail.gmail.com>
The workaround is not to use static compilation for the annotation; it
wouldn't do anything anyway.

On Tue, Apr 15, 2025, 18:53 Saravanan Palanichamy <[email protected]>
wrote:

> It's under Static compilation. I have raised a ticket for this issue. I am
> not sure if there are any work arounds for this issue
>
> regards
> Saravanan
>
> On Tue, Apr 15, 2025 at 6:32 PM Milles, Eric (TR Technology) via dev <
> dev-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected]> wrote:
>
>> You should be able to use "default []".  I don't think it supports
>> "default new Class[0]".  Is this under Static Type Checking or Static
>> Compilation?
>>
>> NOTE: https://issues.apache.org/jira/browse/GROOVY-11492 item 3 covers
>> the missing "default {}" support.
>>
>>
>> ------------------------------
>> *From:* Saravanan Palanichamy <[email protected]>
>> *Sent:* Tuesday, April 15, 2025 4:21 AM
>> *To:* users-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected] <users-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected]>;
>> dev-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected] <dev-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected]>
>> *Subject:* [EXT] Default for annotation members with type class
>>
>> *External Email:* Use caution with links and attachments.
>>
>> Hello Groovy users
>>
>> What is the right way to define this java annotation in groovy? I am
>> testing this out in Groovy 5.0, I have not tried 4.x.
>>
>> I tried using [] after the default keyword, but I get the error
>>
>> "Cannot return value of type java.util.ArrayList<#E> for method returning
>> java.lang.Class<?>[]" and
>> "Cannot return value of type java.util.ArrayList<#E> for method returning
>> java.lang.Class<? extends MyClazz>[]"
>>
>> @Target({ ElementType.*METHOD *})
>> @Retention(RetentionPolicy.*RUNTIME*)
>> public @interface MyAnnotation {
>>
>>     Class<?>[] groups() default {};
>>
>>     Class<? extends MyClazz>[] payloads() default {};
>>
>> }
>>
>>
>> regards
>> Saravanan
>>
>