Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9469

Original exception during global AST transformation no longer preserved in error message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.0, 3.0.2
    • 4.0.0-alpha-1, 3.0.3, 2.5.11
    • Compiler
    • 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

          Activity

            People

              paulk Paul King
              szpak Marcin Zajaczkowski
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h