Re: Default for annotation members with type class
Saravanan Palanichamy <[email protected]> Wed, 16 Apr 2025 05:23:23 +0530
| Newsgroups | gmane.comp.lang.groovy.user |
|---|---|
| Message-ID | <CAG3fL7mHD+B6+F+Ag97CYkt_GARV9aQWQhQDMncrJ6kUAKr3Hg__37523.4827793733$1744761253$gmane$org@mail.gmail.com> |
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 >