GroovyShell
通过(解释器)运行以下 Groovy 表达式:
if(fizz.subtype == null) {
if(fizz.color == 'RED') fizz.subtype = "DOG";
else if(fizz.color == 'BLUE') fizz.subtype = "CAT";
else if(fizz.color == 'GREEN') fizz.subtype = "SHEEP";
else if(fizz.color == 'ORANGE') fizz.subtype = "LION";
else if(fizz.color == 'YELLOW') fizz.subtype = "SNAIL";
else if(fizz.color == 'GRAY') fizz.subtype = "SHARK";
else if(fizz.color == 'PURPLE') fizz.subtype = "BAT";
else if(fizz.color == 'BLACK') fizz.subtype = "FOX";
}; fizz;
给我以下堆栈跟踪:
groovy.lang.MissingPropertyException: No such property: subtype for class: com.me.myapp.Fizz
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:479)
at Script1.run(Script1.groovy:1)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:543)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:518)
at com.tms.evaluator.GroovyEvaluator._evaluate(GroovyEvaluator.java:51)
...rest of stacktrace omitted for brevity
有任何想法吗?提前致谢!