Skip to content

Comments

[groovyscripting] For enum values do import static#19587

Open
dilyanpalauzov wants to merge 1 commit intoopenhab:mainfrom
dilyanpalauzov:groovy_static_import
Open

[groovyscripting] For enum values do import static#19587
dilyanpalauzov wants to merge 1 commit intoopenhab:mainfrom
dilyanpalauzov:groovy_static_import

Conversation

@dilyanpalauzov
Copy link
Contributor

Before this change

@groovy.transform.CompileStatic
def isOn(Object o) {
  return o == ON
}

caused:

[INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/etc/openhab/automation/jsr223/t.groovy'
[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script '/etc/openhab/automation/jsr223/t.groovy': org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/etc/openhab/automation/jsr223/t.groovy: 3: [Static type checking] - The variable [ON] is undeclared.
 @ line 3, column 15.
     return o == ON
                 ^

1 error

[WARN ] [ort.loader.AbstractScriptFileWatcher] - Script loading error, ignoring file '/etc/openhab/automation/jsr223/t.groovy'

With the change, it prints:

[INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/etc/openhab/automation/jsr223/t.groovy'
[DEBUG] [g.internal.GroovyScriptEngineFactory] - Added static import for DOWN
[DEBUG] [g.internal.GroovyScriptEngineFactory] - Added static import for PLAY
[DEBUG] [g.internal.GroovyScriptEngineFactory] - Added static import for ON
…

@dilyanpalauzov dilyanpalauzov requested a review from wborn as a code owner October 30, 2025 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant