wood burning stoves*
The moose likes Java in General and the fly likes Javadocs to Source code generation? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Javadocs to Source code generation?" Watch "Javadocs to Source code generation?" New topic
Author

Javadocs to Source code generation?

Bhiku Mhatre
Ranch Hand

Joined: Feb 11, 2002
Posts: 33
Hi,
I have a set of Javadocs (HTML files) from which I wish to generate class structures (.java files).
Is it possible? (It should be..then how?).
Any tool/API available for this?
I would appreciate any pointers.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Fundamentally, no, this isn't going to be possible. The javadoc does not have enough information in it to do this. It would be possible for you to parse the HTML and extract some information, such as class name, method names & signatures, some fields... but none of the implementing code for methods will be available. This information was ignored when the javadoc was generated, and there's no way to reverse engineer it just using the javadoc.


"I'm not back." - Bill Harding, Twister
john guthrie
Ranch Hand

Joined: Aug 05, 2002
Posts: 124
of course, xdoclet takes javadoc-style comments and generates code...
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Okay john,
Your JR assignment is to create that doclet for the rest of us.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Bhiku Mhatre
Ranch Hand

Joined: Feb 11, 2002
Posts: 33
Hi Jim,
Thanks, and I didn't mean to generate the implementation. I know it's impossible - I was just referring to generating the class structures (methods signatures and variables).
Also I don't think XDoclets would be helpful, because AFAIK it generates code from the embedded comments/tags in the source code - while the scenario here is something else. Am I right?

Originally posted by Jim Yingst:
Fundamentally, no, this isn't going to be possible. The javadoc does not have enough information in it to do this. It would be possible for you to parse the HTML and extract some information, such as class name, method names & signatures, some fields... but none of the implementing code for methods will be available. This information was ignored when the javadoc was generated, and there's no way to reverse engineer it just using the javadoc.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Sounds right, Bhiku. Another issue is that I don't believe there's really a spec for the HTML formatting generated javadoc - Sun could change the format from release to release if they want. This has happened a few times since Java's earliest releases, though since 1.2 it's looked pretty stable. This probably isn't a big issue, but it's something to be aware of. You can study the current HTML format and make a tool that parses it to extract as much code as you can - but you can't really guarantee that the tool will work if Sun makes revisions in the future.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

There's a good chance you could do this to a degree. Not all JavaDocs contain quite everything, so some tweaking might be required.
Of course, since this is reverse-engineering, it's probably either been made illegal under the DMCA or will be under new, improved DMCA V2


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Don't get me started about those stupid light bulbs.
 
subject: Javadocs to Source code generation?
 
Similar Threads
Java EE Download without GlassFish?
Can I jar file and javadoc using JBuilder?
ClassLoader returning null
Hoe to create Java Docs
Search File