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

@TimedInterrupt et al only partially support multiple annotations within a single source file

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2.0-beta-2
    • Component/s: None
    • Labels:
      None

      Description

      @TimedInterrupt has provisions for supporting multiple annotations within the same source file. If for example you do:

      @groovy.transform.TimedInterrupt(value = 2L, applyToAllClasses=false)
      class Class1 { def method1() {} }
      
      @groovy.transform.TimedInterrupt(value = 1L, applyToAllClasses=false)
      class Class2 { def method2() {} }
      
      new Class1().method1()
      new Class2().method2()
      

      All is ok. But if applyToAllClasses is true in either case, or some other occurrence of the annotation occurs at the script level you obtain the rather cryptic compilation error:

      2 compilation errors:
      
      The field 'TimedInterrupt$expireTime' is declared multiple times.
       at line: -1, column: -1
      
      The field 'TimedInterrupt$startTime' is declared multiple times.
       at line: -1, column: -1
      

      Similarly, if you have two methods in a script or class both with an annotation, you will receive the above error.

      I propose to add the hashCode of the annotation into the generated field and also provide an additional "applyToAllMembers" annotation parameter. It will allow the above errors to be avoided.

      The same comments apply (more or less) to @ThreadInterrupt and @ConditionalInterrupt. The same change (with minor tweaks) can be applied to all three.

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              paulk Paul King
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: