You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Harald Fassler (Jira)" <ji...@apache.org> on 2021/05/09 16:58:00 UTC
[jira] [Closed] (GROOVY-10078) Allow static variables in Scripts
[ https://issues.apache.org/jira/browse/GROOVY-10078?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Harald Fassler closed GROOVY-10078.
-----------------------------------
Resolution: Works for Me
> Allow static variables in Scripts
> ---------------------------------
>
> Key: GROOVY-10078
> URL: https://issues.apache.org/jira/browse/GROOVY-10078
> Project: Groovy
> Issue Type: Improvement
> Components: Compiler
> Reporter: Harald Fassler
> Priority: Minor
> Labels: newbie
>
> 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:
> {code:java}
> class Static {
> static staticProperty = 'I am static'
> }
> {code}
> For example groovy.console.ui.view.MacOSXMenuBar.groovy had orgininally this code:
> {code:java}
> static handler = false
> if (!handler) {
> {code}
> ...which was replaced with GROOVY-3768 by this code (and made the variable useless for the originally intented purpose):
> {code:java}
> def handler = false
> if (!handler) {
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)