Inspecting class literal references as annotation parameters in imported classes

So I am trying to find all classes annotated with a specific annotation type in the classpath. This is easy enough. I use this:

    final JavaPsiFacade instance = JavaPsiFacade.getInstance(project);
    final GlobalSearchScope allScope = allScope(project);
    final PsiClass clientMarAnno = instance.findClass(Types.CLIENT_MARSHALLER, allScope);

    for (PsiClass psiClass : searchPsiClasses(clientMarAnno, allScope(project))) {

       // stuff

This works as expected. But here's the the problem:

My @ClientMarshaller annotation accepts a Class<?> as its value(). When the class is declared in my immediate project, I am able to easily extract the class reference from the PsiClassObjectAccessExpression.

But when the annotated class is an imported library, everything changes.

Suddenly, what I see in the PsiAnnoationMemberValue is a PsiLiteralExpression which has a type of PsiPrimitiveType:null, and returns a value of "null".

This is somewhat unexpected. The @ClientMarshaller annotation has a @Retention(RetentionPolicy.RUNTIME), so of course the annotation meta data is present in the class file. Is this not possible to do? Is this a bug?
Comment actions Permalink

This does look like a bug. Could you please post a YouTrack issue?


Please sign in to leave a comment.