Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!198.186.194.247.MISMATCH!news-out.readnews.com!transit3.readnews.com!postnews.google.com!o9g2000vbo.googlegroups.com!not-for-mail From: Alex J Newsgroups: comp.lang.java.programmer Subject: Re: Annotations processing + type introspection + code generation Date: Mon, 12 Sep 2011 11:08:43 -0700 (PDT) Organization: http://groups.google.com Lines: 59 Message-ID: References: <9d6rupF6dkU1@mid.individual.net> <9d6tflFhe3U2@mid.individual.net> NNTP-Posting-Host: 109.205.249.238 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1315851307 21337 127.0.0.1 (12 Sep 2011 18:15:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 12 Sep 2011 18:15:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o9g2000vbo.googlegroups.com; posting-host=109.205.249.238; posting-account=WEhrTAoAAACB_dCNiMk-LATj1SOnQi04 User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HNKRUAELSC X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7910 On Sep 12, 9:22=A0pm, Robert Klemme wrote: > On 12.09.2011 19:04, markspace wrote: > > > > > > > > > > > On 9/12/2011 9:56 AM, Robert Klemme wrote: > > >> The only reason I can think of which would require to generate code > >> would be ultra high speed requirements. > > > I think generated code is somewhat more common that you assume. Since > > the JVM byte codes and class format is public and relatively stable, > > it's quite easy to generate code in a manner that's compatible with > > many, or all, JVMs. > > > There's also things you can't do at runtime. For example, the Proxy > > class requires an interface to extend. But many POJO objects don't > > declare a separate interface. And requiring the programmer to declare a= n > > interface for all POJO types within a framework is pretty odious, and > > old school. > > > I'm playing around with JSF and JPA right now. I notice that all my > > Entity classes are decorated by extending them with generated code. I'm > > sure if there were a better way to do it, they would. But the generated > > code seems to be the way to go in this instance. > > OK, good point! =A0I had generation of boilerplate code (e.g. via things > like XDoclet) in mind which is really 20th century. :-) =A0Depending on > the use case reflection could still be sufficiently fast enough - and > it's likely simpler than byte code generation. XDoclet (http://en.wikipedia.org/wiki/XDoclet, right?) looks quite frightening :) Well, it's not a problem to generate code by simple print calls, entirely without AST or things like that. The main issue is the power enough type introspection as I need to know object model and sometimes methods implementation before code generation. Annotations processing API does not fit my needs, that's why I started to learn javac internals to cast APT interfaces to javac internal interfaces to access AST. > > Kind regards > > =A0 =A0 =A0 =A0 robert > > -- > remember.guy do |as, often| as.you_can - without endhttp://blog.rubybestp= ractices.com/