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

Allow static variables in Scripts

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Works for Me
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Compiler
    • Labels:

      Description

      While working on GROOVY-10077 I found out, that there is actual a use case for allowing static variables in a script when executed in the same JVM instance.

      One can always have a workaround like this:

      class Static {
          static staticProperty = 'I am static'
      }
      

      For example groovy.console.ui.view.MacOSXMenuBar.groovy had orgininally this code:

      static handler = false
      if (!handler) {
      

      ...which was replaced with GROOVY-3768 by this code (and made the variable useless for the originally intented purpose):

      def handler = false
      if (!handler) {
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                nineninesevenfour Harald Fassler
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: