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: 18652
posted
0
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
posted
0
of course, xdoclet takes javadoc-style comments and generates code...
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
posted
0
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
posted
0
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: 18652
posted
0
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.
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
One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"