Getting Type Information

Adrian Kuhn akuhn at
Thu Jun 12 00:11:36 PDT 2008

Hi mgnews (no name?)

Annotation processing happens before the AST is attributed with  
types. That means, the type information is not reachable from an  
annotation processor because it has not yet been computed by the  
compiler itself!

You might give the Spoon project a try, and write a Spoonlet.

Or, you violate JSR 269 and call the type attribution phase yourself  
from the annotation processing plugin. Jamix, a small project of mine  
does exactly that

feel free to extend and change it to your needs, its open source.


Adrian Kuhn
Software Composition Group
University of Bern, Switzerland

On 11 Jun 2008, at 19:59 , mgnews at wrote:

> Oh sorry. I am aware of these tools, but I start from source code.  
> But perhaps I can use one of them after compilation, because only  
> from the source file it's hard to get all type information. My last  
> impression was that none of them fills my needs.
> So I will try to build my own analyzer. I know sorcerer, which is a  
> great tool, but could be better documented :-)
> -------- Original-Nachricht --------
>> Datum: Wed, 11 Jun 2008 09:03:46 -0700
>> Von: Jonathan Gibbons <Jonathan.Gibbons at Sun.COM>
>> An: mgnews at
>> CC: compiler-dev at
>> Betreff: Re: Getting Type Information
>> It depends where you are starting from.   If you have class files  
>> that
>> you want to look at, you might want to analyse those directly,  
>> examining
>> the constant pool for entries that define types. There are several
>> easily available libraries for reading class files.
>> -- Jon
>> mgnews at wrote:
>>> Hello,
>>> I want to extract all external types which are used in a class.
>>> Is there an easy way to do this? I tried the Visitor, but the type
>> information (e.g. for variables) is stored in different ways, so  
>> it's more like
>> a trial and error.
>>> Perhaps I just didn't find the right documentation.
>>> Kind regards

More information about the compiler-dev mailing list