Jump to content
  • Advertisement
Sign in to follow this  
Son of Cain

[java] java.lang.reflect and Code Generation

This topic is 4727 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Here is some ant stuff for a beautifier call to JIndent (for copy paste purposes), this is just a ant target:


<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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!