lang tools : how to get "TypeElement" for a local variable
Mayuresh
mayuresh at acm.org
Mon Nov 10 05:50:59 PST 2008
Jon, Thanks.
I tried and figured out from code that many such elements are built post
annotation processing. Unfortunately plugging in custom code to access these
structures seems to be feasible only in annotation processing phase.
Is there any way (using published interface as far as possible) to either
invoke building of these elements prior to/during annotation processing or
alternatively accessing them after they have been built?
Mayuresh.
> Jonathan Gibbons <Jonathan.Gibbons at Sun.COM>
> Sent by: Jonathan.Gibbons at Sun.COM
> 11/09/2008 21:25 PST
>
> To mayuresh at acm.org
> cc compiler-dev at openjdk.java.net
> bcc
> Subject Re: lang tools : how to get "TypeElement" for a local variable
>
>
> I would guess the most likely cause is that you are asking for the info
> before it has been evaluated. The TypeElements for the members
> and methods are determined fairly early; the TypeElements for the
> local variables is determined much later, when the containing
> method is being analyzed prior to being code generated.
>
> -- Jon
>
> On Nov 9, 2008, at 9:29 AM, Mayuresh wrote:
> > Hi
> >
> > I was exploring the syntax tree exposed by Compiler API using
> > TreePathScanner
> > based visitor.
> >
> > I am trying to get the "TypeElement" for a variable declaration to
> > extract
> > qualified type of the variable etc.
> >
> > I am using Trees.getElement() to get the TypeElement to which I pass
> > current
> > path at a VariableTree node.
> >
> > I can get the Element for member or method parameter declaration
> > though for
> > local variables Element returned is null.
> >
> > Is this a bug? Is there some other way to get TypeElement?
> >
> > Mayuresh.
>
> ForwardSourceID:NT00026412
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
More information about the compiler-dev
mailing list