Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #7900

Re: Annotations processing + type introspection + code generation

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Annotations processing + type introspection + code generation
Date 2011-09-12 18:56 +0200
Message-ID <9d6rupF6dkU1@mid.individual.net> (permalink)
References <b4cda2f5-442e-42f3-af75-5040215ba997@k15g2000yqd.googlegroups.com>

Show all headers | View raw


On 12.09.2011 15:21, Alex J wrote:
> Hi all,
>
> I need a annotation processing tool with the possibility to generate
> source code.
> What I want to do is to process specific annotations *and* generate
> boilerplate code to the newly introduced classes that I plan to use
> via ServiceLoader.
>
> In fact, I can do that with Open JDK (by using the standard annotation
> processing facility which is built-in to the javac compiler starting
> from the Java 6), but deep type introspection and code generations
> require to use sun-specific classes (basically com.sun.tools.javac.*)
> which obviously is an ugly hack, not to mention that
> (1) they change internal AST and Type tree representations from
> release to release
> (2) the interface to internal AST (JCTree descendants) is ugly - most
> classes expose public fields, extensively use bit flags and have
> complex and cluttered API.
>
> I believe that there is a better way to do that (annotations
> processing + type (AST) introspection + code generation) but I don't
> know what tool I should use.
>
> P.S.: I'm using maven and I'd like to do that in IDE-independent way.
> P.P.S: Downgrading to JDK 5 is inappropriate.

Why do you want to generate code?  I mean, you could process annotations 
at runtime.  Create appropriate classes for the handling and configure 
appropriate graphs of objects which do the work (or even use reflection).

The only reason I can think of which would require to generate code 
would be ultra high speed requirements.  But before I would go down that 
road I'd first make sure that the other approach is not fast enough 
(i.e. implement and measure).  If it is, you can stop there and be done.

Kind regards

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Annotations processing + type introspection + code generation Alex J <vstrength@gmail.com> - 2011-09-12 06:21 -0700
  Re: Annotations processing + type introspection + code generation Robert Klemme <shortcutter@googlemail.com> - 2011-09-12 18:56 +0200
    Re: Annotations processing + type introspection + code generation markspace <-@.> - 2011-09-12 10:04 -0700
      Re: Annotations processing + type introspection + code generation Robert Klemme <shortcutter@googlemail.com> - 2011-09-12 19:22 +0200
        Re: Annotations processing + type introspection + code generation Alex J <vstrength@gmail.com> - 2011-09-12 11:08 -0700
    Re: Annotations processing + type introspection + code generation Alex J <vstrength@gmail.com> - 2011-09-12 11:00 -0700
      Re: Annotations processing + type introspection + code generation Robert Klemme <shortcutter@googlemail.com> - 2011-09-12 20:21 +0200
        Re: Annotations processing + type introspection + code generation Alex J <vstrength@gmail.com> - 2011-09-12 15:06 -0700

csiph-web