- A Concurrent Affair - https://www.concurrentaffair.org -

Javadoc Processing a File It Doesn’t Need To

I’m running the command line Javadoc tool. In the current directory, I have two files, A.java (which is syntactically correct), and a Broken.java (which has a syntax error in it). A.java doesn’t refer to Broken.java.

File A.java:

1
2
3
4
import javax.swing.JApplet;

public class A extends JApplet [1] {
}

File Broken.java:

1
class class Broken

When I try to Javadoc just A.java using the command line

javadoc -d doc A.java

I get this output with an error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$ javadoc -d doc A.java
Loading source file A.java...
Constructing Javadoc information...
Standard Doclet version 1.6.0_21
Building tree for all the packages and classes...
Generating doc\A.html...
Generating doc\package-frame.html...
Generating doc\package-summary.html...
Generating doc\package-tree.html...
Generating doc\constant-values.html...
Generating doc\serialized-form.html...
.\Broken.java:1: <identifier> expected
class class Broken
     ^
.\Broken.java:1: reached end of file while parsing
class class Broken
                  ^
Building index for all the packages and classes...
Generating doc\overview-tree.html...
Generating doc\index-all.html...
Generating doc\deprecated-list.html...
Building index for all classes...
Generating doc\allclasses-frame.html...
Generating doc\allclasses-noframe.html...
Generating doc\index.html...
Generating doc\help-doc.html...
Generating doc\stylesheet.css...
2 errors

If I don’t have an “extends” clause for the class A, then Javadoc doesn’t try to process the Broken.java file.

Can somebody please tell me why Javadoc is looking at Broken.java, and how I can prevent it from doing that? How do I tell Javadoc to just process the file I am specifying?

I’m using a Mac with OS X 10.4, Java 5, but this also occurs on Windows with Java 6 Update 21.

I was told to just fix the syntax error [2], but as IDE developer, that’s obviously not the solution for me. I can’t tell my users to “just fix the syntax error”.

[3] [4]Share [5]
1 Comment (Open | Close)

1 Comment To "Javadoc Processing a File It Doesn’t Need To"

#1 Comment By StephenGilbert On July 24, 2010 @ 15:34

Hi,
The documentation for A seems fine, but the file produced for the Serialized Form shows the B class and that’s what fails. In the file com.sun.tools.doclets.standard.SerializedFormWriter it looks like the method
protected void generateContents(RootDoc root) first looks at all classes in the list of packages before looking at the classes specified on the command line.

–STeve