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/05 15:00:00 UTC

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

Paul King created GROOVY-10679:
----------------------------------

             Summary: 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
            Reporter: Paul King
            Assignee: Paul King


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}




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