Getting Type Information
Adrian Kuhn
akuhn at iam.unibe.ch
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.
http://spoon.gforge.inria.fr/
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
https://www.iam.unibe.ch/scg/svn_repos/Sources/Jamix
feel free to extend and change it to your needs, its open source.
cheers,
AA
--
Adrian Kuhn
Software Composition Group
University of Bern, Switzerland
http://www.iam.unibe.ch/~akuhn
On 11 Jun 2008, at 19:59 , mgnews at gmx.de 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 gmx.de
>> CC: compiler-dev at openjdk.java.net
>> 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 gmx.de 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