Uploaded image for project: 'Clover'
  1. Clover
  2. CLOV-1490

Clover safeEval method is imcompatible with Groovy's @CompileStatic annotation

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • 4.0.1
    • 3.3.0
    • Groovy
    • None
    • Groovy Version - 2.1.3
      Clover Version - 3.3.0
      Java Version - 1.7.0

      When trying to use Clover on a Groovy class that is marked @CompileStatic and it contains a null-safe operator (e.g. Bar bar = foo?.bar), then the groovyc compilation fails with the error:

      No such property: bar for class: java.lang.Object

      The error is that the generated

      $CLV_safeEval${code} method returns an Object instead of the type of the property. This then causes Groovy compiler to fail later.
      
      I've created a sample project that exhibits the problem at https://github.com/johnrengelman/clover-grooyv-compilestatic
      
      Simply run 

      ./gradlew test

      
      

            [CLOV-1490] Clover safeEval method is imcompatible with Groovy's @CompileStatic annotation

            In case the problem still persists, may I ask you to:

            1) Run the build with 'grails test-app -clover.on --verbose -Dclover.grover.ast.dump=true'. This will cause that Clover will dump AST (abstract syntax trees) to your java.io.tmpdir directory. You'll see messages in log like:

            [clover-setup] Original source for <path to A.groovy> written to <java.io.tmpdir>\ast\A.groovy.before.clovered
            [clover-setup] Instrumented source for <path to A.groovy> written to <java.io.tmpdir>\ast\A.groovy.after.clovered
            

            2) Attach *.before.clovered and *.after.clovered files for a single groovy class which does not compile due to the safeEval() problem?

            3) Could you also remove the @CompileStatic annotation and run a build again (it should succeed) and attach the *.class file produced?

            I'd like to analyze it.

            Marek Parfianowicz added a comment - In case the problem still persists, may I ask you to: 1) Run the build with 'grails test-app -clover.on --verbose -Dclover.grover.ast.dump=true'. This will cause that Clover will dump AST (abstract syntax trees) to your java.io.tmpdir directory. You'll see messages in log like: [clover-setup] Original source for <path to A.groovy> written to <java.io.tmpdir>\ast\A.groovy.before.clovered [clover-setup] Instrumented source for <path to A.groovy> written to <java.io.tmpdir>\ast\A.groovy.after.clovered 2) Attach *.before.clovered and *.after.clovered files for a single groovy class which does not compile due to the safeEval() problem? 3) Could you also remove the @CompileStatic annotation and run a build again (it should succeed) and attach the *.class file produced? I'd like to analyze it.

            I have attached the pre-release build of Clover for Grails version 4.0.1. Could you please update dependency in your BuildConfig.groovy, i.e.:

                plugins {
                    compile ":clover:4.0.1"
                }
                dependencies {
                    compile "com.atlassian.clover:clover:4.0.1-SNAPSHOT"
                }
            

            and run the build again? I'd like to ensure that you indeed use the same version.

            Marek Parfianowicz added a comment - I have attached the pre-release build of Clover for Grails version 4.0.1. Could you please update dependency in your BuildConfig.groovy, i.e.: plugins { compile ":clover:4.0.1" } dependencies { compile "com.atlassian.clover:clover:4.0.1-SNAPSHOT" } and run the build again? I'd like to ensure that you indeed use the same version.

            Marek Parfianowicz added a comment - grails-clover-4.0.1-pre-release.ZIP

            FYI, we ran across this today. I tried using the 4.0.1-SNAPSHOT above but it doesn't seem to fix the issue.

            I confirmed that I'm using the 4.0.1 version for the clover dependency (I exclude 'clover' from the 4.0.0 plugin version).

            Aaron Long added a comment - FYI, we ran across this today. I tried using the 4.0.1-SNAPSHOT above but it doesn't seem to fix the issue. I confirmed that I'm using the 4.0.1 version for the clover dependency (I exclude 'clover' from the 4.0.0 plugin version).

            Marek Parfianowicz added a comment - https://maven.atlassian.com/content/repositories/atlassian-central-snapshot/com/atlassian/clover/clover/4.0.1-SNAPSHOT/

            Thanks a lot for reporting this John. I'm adding this to a release backlog.

            Marek Parfianowicz added a comment - Thanks a lot for reporting this John. I'm adding this to a release backlog.

              mparfianowicz Marek Parfianowicz
              41d7a72aec2c John Engelman
              Affected customers:
              2 This affects my team
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: