Getting Type Information

Maurizio Cimadamore Maurizio.Cimadamore at Sun.COM
Wed Jun 11 11:07:57 PDT 2008


Hi
What about using an annotation processor? It should give you what you 
need (the ability of inspecting fields, methods classes declared by a 
class).

Some basic documentation about annotation processing: 
http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Processor.html#getSupportedAnnotationTypes()

Note: if you make your processor's getSupportedAnnotationTypes to return 
'*', that should allow you to process every element in a source file, 
even those without annotations.

Maurizio

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