Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0.0, 3.0.2
-
None
-
Patch
Description
Global AST transformation in Spock throws exception with meaningful error message if used with incompatible Groovy version (e.g. Spock for Groovy 2.5 executed with Groovy 2.4):
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/.../spock-core-1.3-groovy-2.5.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception org.spockframework.util.IncompatibleGroovyVersionException: The Spock compiler plugin cannot execute because Spock 1.3.0-groovy-2.5 is not compatible with Groovy 2.4.3. For more information, see http://versioninfo.spockframework.org Spock artifact: file:/.../spock-core-1.3-groovy-2.5.jar Groovy artifact: file:/.../groovy-2.4.3.jar
However, it stopped working with Spock 2.0 for Groovy 2.5 and Groovy 3.0:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at
jar:file:/.../spock-core-2.0-M1-groovy-2.5.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation
because of exception java.lang.reflect.InvocationTargetException
It's not very constructive for people seeing that error message. Firstly, I suspected some incompatibilities in the Spock code which completely fails with new Groovy. However, it turned out that the exception is hidden by Groovy itself.
I slightly modified ASTTransformationVisitor it detect that situation and get target/cause in a case of InvocationTargetException - my PR.
It helped, however, I haven't found any change in the ASTTransformationVisitor which could cause that regression. It might to some 2.5→3.0 change how constructor are called (e.g. around CachedConstructor which is used, but doesn't seem to intercept the exception) or anything else. You might want to investigate it - it worked without my tweak in Groovy 2.5.
Related Spock issues: https://github.com/spockframework/spock/issues/1067
Attachments
Issue Links
- links to