views:

337

answers:

5

I am working with a proprietary library that has JavaDocs, but no source code. I've attached the JavaDocs to the library's jar, but I still can't get useful parameter names auto-completed (they are named arg0, arg1, arg2, etc). Is there any way to fix this without source code?

+1  A: 

Parameter names, like local variables, are removed when the source code gets compiled down to byte-code. Even if you have @param elements in the Javadoc, they aren't guaranteed to be in any order and some can even be missing. I don't think there is a reliable way for the IDE to reconstruct which @param maps to which parameter using the Javadoc alone.

Outlaw Programmer
Thanks for the reply, but I think that it is possible. The JavaDoc has the complete message signature, including parameter names. Example copied from Sun's System JavaDoc:static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
Joel
Hey, it looks like you're right. It should be possible for the IDE to at least take a good guess at the parameters names.
Outlaw Programmer
A: 

No, the variable names are lost during compilation.

Nick Holt
Right. I was hoping to get eclipse to use information contained in the JavaDocs instead.
Joel
+1  A: 

I do not believe that Eclipse can do much more with attached javadocs than point a browser at the right page.

I would suggest looking for a program which can recreate a source jar (just the stubs) from JavaDoc files, and then attach that to your proprietary file. Eclipse should then pick up the information you want from that.

Thorbjørn Ravn Andersen
A: 

I would recommend installing JD-Eclipse:

It is a Java Decompiler and allows you to peek into the classes you don't have the source/JavaDoc of. Looking at the source may allow you to determine what the unnamed parameters are used for.

DevJ
A: 

I think Eclipse have this feature from version 3.2 (see this bug). I have just tried with Oracle's jdbc driver (no source but javadoc). Before attaching the javadoc to the jar I have only arg1,... for parameter completing. After attaching the javadoc I have both javadoc and correct parameter name completing.

But... this only works if you attach the javadoc as a "javadoc in archive", and does not work when you use javadoc URL.

Csaba_H
Hey, that is exactly what I was looking for. Just tried it and it workd. Thanks! (I had been just using the local path)
Joel