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

AnnotationCollector not removed during stub generation

    XMLWordPrintableJSON

Details

    Description

      The Groovy Stubs generator leaves the AnnotationCollectors in the generator stubs sources instead of replacing them with the collected annotations, which in turn causes javac to fail, since they are not valid annotations. (Related to GROOVY-7056)

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project example: Compilation failure
      [ERROR] /C:/dev/github/groovy-stubs-annotation/target/generated-sources/groovy-stubs/main/org/example/Service.java:[19,18] incompatible types: groovy.transform.CompileDynamic cannot be converted to java.lang.annotation.Annotation

      Groovy Source
      @CompileStatic
      class Service {
      
        @CompileDynamic
        List<String> dynamic() {
          []
        }
      }
      

      gets transformed into

      Generated Stub
      @groovy.transform.CompileStatic() public class Service
        extends java.lang.Object  implements
          groovy.lang.GroovyObject {
      @groovy.transform.CompileDynamic() public  java.util.List<java.lang.String> dynamic() { return (java.util.List<java.lang.String>)null;}
      }
      

       

      See attached Project to reproduce

      For groovy 2.4.15: ./mvnw clean install

      For groovy 2.5.2: ./mvnw clean install -Pgroovy-2.5

      Attachments

        1. groovy-stubs-annotation.zip
          49 kB
          Leonard Brünings

        Activity

          People

            Unassigned Unassigned
            leonard84 Leonard Brünings
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: