You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/07/14 09:34:00 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=17566732#comment-17566732 ] 

ASF GitHub Bot commented on GROOVY-10679:
-----------------------------------------

paulk-asert commented on PR #1746:
URL: https://github.com/apache/groovy/pull/1746#issuecomment-1184219784

   I haven't yet created a constant for "_SKIPPABLE_ANNOTATIONS" and similarly there is a private but not public constant for "_RECORD_HEADER". We could make public constants or usage could easily be hidden behind some API. I was just avoiding new API in the first instance but I welcome feedback.




> 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
>
> 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)