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

Cross compilation of Groovy annotation on Java class does not work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.0, 2.1.1
    • 2.1.2, 2.2.0-beta-1
    • Compiler
    • originally: Linux jato-rafal 3.0.0-31-generic #49-Ubuntu SMP Tue Feb 19 20:02:57 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
      reproduced on Windows 7 x64

    Description

      This annotation:

      @Retention(RetentionPolicy.RUNTIME)
      @Target([ElementType.TYPE, ElementType.METHOD])
      @interface Tx {
      
          String value() default 'def'
      }
      

      on this class:

      @Tx
      public class PersonServiceJava {
      }
      

      results in the following failure:

      $ groovyc -j PersonServiceJava.java Tx.groovy
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Compile error during compilation with javac.
      /home/wujek/Playground/annotation_test/src/main/groovy/test/PersonServiceJava.java:4: error: annotation Tx is missing value for the attribute value
      @Tx
      ^
      1 error

      I originally submitted it to Gradle (http://issues.gradle.org/browse/GRADLE-2682), but it seems to be a core groovy issue. The generated stub for the Groovy annotation look like the following:

      @java.lang.annotation.Retention(value=java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target(value={java.lang.annotation.ElementType.TYPE,java.lang.annotation.ElementType.METHOD}) public @interface Tx
       {
       java.lang.String value();
      }
      

      The default value is missing. A sample project can be downloaded in the Gradle issue, so I won't attach it here, unless you want me to.

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              wujek.srujek wujek srujek
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: