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?