groovy
  1. groovy
  2. GROOVY-4354

Stub Generator does not add .class for classes in annotations

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 1.7.4
    • Fix Version/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The Groovy Stub generator does not add a .class extension for Class usages in annotations. For example, generating stubs for the following doesn't work:

          @Test(expected = IllegalArgumentException)
          void shouldFailOnDifferentCurrencies() {
             // impl
          }
      

      For more information, see GMAVEN-79

        Issue Links

          Activity

          Hide
          Peter Niederwieser added a comment - - edited

          See Groovy trunk, class JavaStubGenerator, line 624. Class literal is considered a VariableExpression (because we are still in phase conversion), and its source code is generated with ASTNode.getText(). Question is how to tell that it's a class literal. I was surprised that I could access the annotation attribute's type with "annotation.getClassNode().getTypeClass().getDeclaredMethod(key, null).getReturnType()". Hence I assume this solves the problem for referenced Java/Groovy classes that aren't part of the same compilation unit. For the rest we could think about applying some heuristics, unless there is a better approach I'm missing. Jochen, what's your take on this?

          Show
          Peter Niederwieser added a comment - - edited See Groovy trunk, class JavaStubGenerator, line 624. Class literal is considered a VariableExpression (because we are still in phase conversion), and its source code is generated with ASTNode.getText(). Question is how to tell that it's a class literal. I was surprised that I could access the annotation attribute's type with "annotation.getClassNode().getTypeClass().getDeclaredMethod(key, null).getReturnType()". Hence I assume this solves the problem for referenced Java/Groovy classes that aren't part of the same compilation unit. For the rest we could think about applying some heuristics, unless there is a better approach I'm missing. Jochen, what's your take on this?
          Hide
          blackdrag blackdrag added a comment -

          We run a simplified class resolving. Seems that is not including the annotation values. annotation.getClassNode().getTypeClass() will work only if the annotation is backed up by a class.

          Show
          blackdrag blackdrag added a comment - We run a simplified class resolving. Seems that is not including the annotation values. annotation.getClassNode().getTypeClass() will work only if the annotation is backed up by a class.
          Hide
          Travis added a comment -

          Just ran into this. It is still happening on groovy 1.7.8 & 1.8-rc-1. Figured I'd mention it since the affects version says 1.7.4

          Show
          Travis added a comment - Just ran into this. It is still happening on groovy 1.7.8 & 1.8-rc-1. Figured I'd mention it since the affects version says 1.7.4
          Hide
          Guillaume Laforge added a comment -

          It's covered by GROOVY-4517

          Show
          Guillaume Laforge added a comment - It's covered by GROOVY-4517

            People

            • Assignee:
              Guillaume Laforge
              Reporter:
              Erik Pragt
            • Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: