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

Compiler should enforce that annotation value w/o default is provided

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6
    • 1.6.3, 1.7-beta-1
    • Compiler
    • None

    Description

      import java.lang.annotation.Retention
      import java.lang.annotation.RetentionPolicy
      
      @Retention(RetentionPolicy.RUNTIME)
      @interface Foo {
        String x()
      }
      
      @Foo // compiler should not allow this, because there is no default value for x
      class Bar {}
      
      def anno = Bar.class.getAnnotation(Foo)
      anno.x() // java.lang.annotation.IncompleteAnnotationException: Foo missing element x
      

      Attachments

        1. 3454_v16x.txt
          3 kB
          Roshan Dawrani

        Issue Links

          Activity

            People

              roshandawrani Roshan Dawrani
              pniederw Peter Niederwieser
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: