[java] java.lang.reflect and Code Generation
Hi folks,
My current project must generate Java code, and so I have to design a class that represents a legal Java method.
I've searched google extensively, but all I got was tutorials about how to retrive information about methods of an existing class - which is not what I need.
So, do you guys know of a good book or tutorial that deals with reflect?
I've seen the Type and TypeVariable interfaces, as well as GenericDeclaration, but I couldn't figure out a way of working with them in order to generate code. Can you guys brainstorm for a while? ;)
Son Of Cain
Thanks rohde, great links!
BTW, if you guys know of any "code beautifier" library, please mention it here ;)
Son Of Cain
BTW, if you guys know of any "code beautifier" library, please mention it here ;)
Son Of Cain
Exactly that, thank you =D
BTW, I sticked with Velocity and its templates to generate the code I need. Fast and easily customizable!
Son Of Cain
BTW, I sticked with Velocity and its templates to generate the code I need. Fast and easily customizable!
Son Of Cain
Here is some ant stuff for a beautifier call to JIndent (for copy paste purposes), this is just a ant target:
You'll also need the JIndent pure java downloads from JIndent.com, and to put the jars from that download in the /lib dir of your project. This is not the JIndent-ant.jar but nearly all the other jars that come with the d/l.
It's nice, and you can edit this to accept a file with your custome format preferences, just like checkstyle, that is incase you find checkstyle not up to par. I don't remember if checkstyle accepts java1.5 -- I knodw the jalopy documentation says only to 1.4.1 (or so).
L-
[Edited by - Lucidquiet on August 5, 2005 4:22:55 PM]
<pre> <!-- ================================================================== --> <!-- Format Source Code recursively throughout the source tree --> <!-- ================================================================== --> <target name="format" depends="compile" description="JIndent Format" > <java jar="lib/Jindent.jar" fork="true" classpathref="classpath" > <arg value="-r" /> <arg value="${src}" /> </java> </target></pre>
You'll also need the JIndent pure java downloads from JIndent.com, and to put the jars from that download in the /lib dir of your project. This is not the JIndent-ant.jar but nearly all the other jars that come with the d/l.
It's nice, and you can edit this to accept a file with your custome format preferences, just like checkstyle, that is incase you find checkstyle not up to par. I don't remember if checkstyle accepts java1.5 -- I knodw the jalopy documentation says only to 1.4.1 (or so).
L-
[Edited by - Lucidquiet on August 5, 2005 4:22:55 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement