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

Groovy should have an @AutoFinal annotation


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


      When defined on a method or constructor, all parameters of that method/constructor will be final. When applied on a class, the annotation applies to all methods/constructors.

      Discussion points:

      1. Should visibility matter, e.g. would it apply to all public, protected, private, etc. members, or does there need to be some ability to customise? Current thinking: it should apply to all methods. We can always introduce an additional annotation attribute at a later point if there is demand.
      2. Should there be support for 'includes' or 'excludes' functionality? Current thinking: don't support this for now. The annotation can be applied on multiple methods/constructors if finer granularity than the class level is required.
      3. Should the annotation apply to fields/properties? Applying 'final' to a field/property seems to be more efficient than applying @AutoFinal but would there ever be a desire to apply such an annotation to all fields/properties? Current thinking: don't support this for now. An annotation attribute could be added later if we wanted to optionally turn such extra cases on.
      4. Should it apply to synthetic methods/constructors added by the compiler/other transforms? Current thinking: Don't apply to synthetic methods unless we find special cases were it is needed.
      5. What phase should this run at? It needs to be before the (incubating) final variable analyser is run. Current thinking: SEMANTIC_ANALYSIS
      6. We should have tests to confirm that there are no adverse interactions with other language features, e.g. default parameter values. Note: we should have a test case that covers this.


          Issue Links



              • Assignee:
                paulk Paul King
                paulk Paul King
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: