Yes, those errors are with type checking turned on. We have special handling for that elsewhere but maybe not here yet?
On Tue, Apr 15, 2025 at 11:02 PM Milles, Eric (TR Technology) via dev < dev@groovy.apache.org> 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 <chava...@gmail.com> > *Sent:* Tuesday, April 15, 2025 4:21 AM > *To:* us...@groovy.apache.org <us...@groovy.apache.org>; > dev@groovy.apache.org <dev@groovy.apache.org> > *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 >