Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.8.6, 2.0.1
-
None
-
None
Description
The following code will fail:
def program = "println 'hello world'; while(true) {;}" def config = new CompilerConfiguration() config.addCompilationCustomizers(new ASTTransformationCustomizer([value: 1L, unit: TimeUnit.MILLISECONDS],TimedInterrupt)) GroovyShell sh = new GroovyShell(config) Script script = sh.parse(program) System.out.println(script.run()) // fail here
With the exception:
org.codehaus.groovy.classgen.ClassGeneratorException: Cannot generate bytecode for constant: MILLISECONDS of type: java.util.concurrent.TimeUnit$3
Per blackdrag, this is apparently a bug in line 197 of TimedInterruptableASTTransformation, which uses ConstantExpression when it should have used PropertyExpression.
As a result of this bug, the only TimeUnit available when using TimedInterrupt is TimeUnit.SECONDS, which is the default. This is probably not too big of an issue for most uses, which is why I've set the priority to Minor.