[ 
https://issues.apache.org/jira/browse/GROOVY-10855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17638431#comment-17638431
 ] 

Paul King commented on GROOVY-10855:
------------------------------------

Missing Retention and/or Target isn't necessarily an error in general. 
Retention defaults to RetentionPolicy.CLASS. Target defaults to any declaration 
except a type parameter declaration. Having said that, CLASS doesn't make sense 
for annotation collectors which are replaced and not kept even at the class 
level. But see historical info below.

Historically we had numerous annotations with retention set to RUNTIME. There 
was the potential for tools to make use of that information, potentially 
replacing the need for JavaBean BeanInfo classes in some circumstances or 
allowing utility methods for BeanDescriptor and/or PropertyDescriptor style 
processing. As far as we know, no such tools were written (or at least none 
became popular). Over time we started switching back to SOURCE. We could 
certainly consider dropping RUNTIME to at least CLASS which would eliminate the 
potential for tools using runtime introspection or to SOURCE which would also 
disallow ASM-style processing tools. That would be a breaking change, so a 
version 5+ thing I would think.

There was also evolution that took place. @Immutable was originally not an 
annotation collector.
So that Groovy could process class files compiled in earlier versions, we kept 
RUNTIME for its retention. It also has deprecated annotation attributes which 
are ignored. Any introspected class files with that annotation can still be 
processed, though again we aren't necessarily aware of any tools or scripts 
that do such processing. It's been quite some time since @Immutable was made a 
meta-annotation, so perhaps we could release note that we no longer support 
reading that annotation from class files with those old Groovy versions. We'd 
need to do some testing. I have a vague re-collection that adding back in the 
"backwards compatible reading of @Immutable" was only partly done to be nice 
from a compatibility point of view - there were actually errors at the ASM 
level (maybe? class mismatch errors?) if the annotation was found but didn't 
match what the definition said.

> Meta-annotation retention policy and target
> -------------------------------------------
>
>                 Key: GROOVY-10855
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10855
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Priority: Minor
>
> Groovy collector annotations {{@Canonical}}, {{@Immutable}}, {{@RecordType}} 
> and {{@CompileDynamic}} have missing or misleading {{Retention}} and 
> {{Target}} metadata.  _Note:_ there may be others...
> {{@Canonical}} and {{@CompileDynamic}}: missing {{Retention}} and {{Target}}
> {{@Immutable}} and {{@RecordType}}: {{RetentionPolicy}} is {{RUNTIME}} but 
> should be {{SOURCE}} since meta-annotation is not retained.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to