Следующий код может прекрасно скомпилироваться в Intellij, но при попытке использовать Groovy в качестве скрипта выдает ошибку даже перед запуском.
Я не могу найти трещину, так как на самом деле все статично?
public enum OutputType {
ABC,
DEF,
GHI
}
//Just initializing here
public static OutputType output=OutputType.ABC;
public static void run() {
switch (output){
case ABC:
runABC();
break;
case DEF:
runDEF();
break;
case GHI:
runGHI();
break;
default:
break;
}
}
Ошибка:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 50: Apparent variable 'ABC' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method 'ABC' but left out brackets in a place not allowed by the grammar.
@ line 50, column 18.
case ABC:
^
Script1.groovy: 54: Apparent variable 'DEF' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method 'DEF' but left out brackets in a place not allowed by the grammar.
@ line 54, column 18.
case DEF:
^
Script1.groovy: 58: Apparent variable 'GHI' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method 'GHI' but left out brackets in a place not allowed by the grammar.
@ line 58, column 18.
case GHI: