Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
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.