You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (JIRA)" <ji...@apache.org> on 2019/07/25 16:00:00 UTC

[jira] [Updated] (GROOVY-9206) Cannot use annotation with attribute of type char

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

Eric Milles updated GROOVY-9206:
--------------------------------
    Description: 
Consider the following:
{code:groovy}
import java.lang.annotation.*;
@Target(ElementType.FIELD)
public @interface A {
  char value();
}

​class C {
  @A((char)';')
  String tokens
}
{code}

This errors with: {{Expected '(char) ;' to be an inline constant of type char in @A}}.  I've tried a bare 1-character string literal, coercion, an int literal, and assignment to a static final field/property with similar results.  Not sure if it is possible to use this annotation without some kind of fix.

  was:
Consider the following:
{code:groovy}
import java.lang.annotation.*;
@Target(ElementType.FIELD)
public @interface A {
  char value();
}

​class C {
  @A((char)';')
  String tokens
}
{code}

This errors with: {{Expected '(char) ;' to be an inline constant of type char in @A}}.  I've tried a bare 1-character string literal, coercion, and assignment to a static final field/property with similar results.  Not sure if it is possible to use this annotation without some kind of fix.


> Cannot use annotation with attribute of type char
> -------------------------------------------------
>
>                 Key: GROOVY-9206
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9206
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> import java.lang.annotation.*;
> @Target(ElementType.FIELD)
> public @interface A {
>   char value();
> }
> ​class C {
>   @A((char)';')
>   String tokens
> }
> {code}
> This errors with: {{Expected '(char) ;' to be an inline constant of type char in @A}}.  I've tried a bare 1-character string literal, coercion, an int literal, and assignment to a static final field/property with similar results.  Not sure if it is possible to use this annotation without some kind of fix.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)