You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/07/19 03:47:00 UTC

[jira] [Resolved] (GROOVY-10679) Annotations not being correctly placed in native records

     [ https://issues.apache.org/jira/browse/GROOVY-10679?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King resolved GROOVY-10679.
--------------------------------
    Fix Version/s: 5.0.0-alpha-1
                   4.0.4
       Resolution: Fixed

> Annotations not being correctly placed in native records
> --------------------------------------------------------
>
>                 Key: GROOVY-10679
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10679
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.3
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>              Labels: annotations
>             Fix For: 5.0.0-alpha-1, 4.0.4
>
>
> For this code:
> {code:java}
> import java.lang.annotation.*
> import groovy.transform.TupleConstructor
> @Target([ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER])
> @Retention(RetentionPolicy.RUNTIME)
> public @interface MyAnno { }
> @MyAnno
> record Car(String make, @MyAnno String model) { }
> assert !Car.getAnnotation(MyAnno)
> assert Car.getMethod('model').getAnnotation(MyAnno)
> assert Car.getConstructor(String, String).getAnnotation(MyAnno)
> assert Car.getConstructor(String, String).getParameterAnnotations()[1][0].annotationType() == MyAnno
> {code}
> Groovy 4 on JDK17 currently fails with:
> {noformat}
> Annotation @MyAnno is not allowed on element RECORD_COMPONENT
> {noformat}
> So, the annotation is showing up where it shouldn't.
> In addition, the annotation isn't showing up in other places where it should.
> TL;DR: We have this working for some cases but not all.



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