Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9206

Cannot use annotation with attribute of type char

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.4
    • None

    Description

      Consider the following:

      import java.lang.annotation.*;
      @Target(ElementType.FIELD)
      public @interface A {
        char value();
      }
      
      ​class C {
        @A((char)';')
        String tokens
      }
      

      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.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: