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

Java stub generator doesn't use FQN for annotation values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.7.5
    • 1.7.6, 1.8-beta-3
    • Compiler
    • None

    Description

      After upgrading our app from 1.7.4 to 1.7.5, we got several (joint) compile errors for seemingly simple Groovy classes. Looking at the generated stub code, I found that imports for annotations were always missing. After debugging groovyc, I found the following:

      AntlrParserPlugin:333: addImport() is called with alias==null, which is correct since no import alias is used
      ASTHelper:131: if(aliasName==null) aliasName=name // now alias is non-null
      JavaStubGenerator:679: if (imp.getAlias() == null) imports.add(...); // because getAlias() is non-null, import isn't added

      Code example:

      import foo.Foo // details of Foo don't matter
         
      @Foo
      class Bar {} 
      

      For GMaven users this means that if just one Groovy class in the whole project contains an annotation, the project cannot be compiled.

      Attachments

        1. 4434_v18x.diff
          12 kB
          Roshan Dawrani

        Activity

          People

            roshandawrani Roshan Dawrani
            pniederw Peter Niederwieser
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: