Community
Participate
Working Groups
20050127 Look at the AST of the following code: The package declaration should have the Javadoc node set (new in 5.0) /** * */ package pack; public class E { }
I think the bug needs some more explanation. As there is only one file from which the documentation about the package should be taken, which should be called "package-info.java". Otherwise several .java files could override the package-javadoc. References: http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#packagecomment Example source (package-info.java): /** * Provides the classes necessary to create an applet and the classes an applet uses * to communicate with its applet context. * <p> * The applet framework involves two entities: * the applet and the applet context. An applet is an embeddable window (see the * {@link java.awt.Panel} class) with a few extra methods that the applet context * can use to initialize, start, and stop the applet. * * @since 1.0 * @see java.awt */ package testPackageInfo;
Jim, what was the reason for adding a Javadoc property to the package declaration node? The link from comment 1 only mentions types, methods and fields where Javadoc comments are recognized.
The link in comment 1 shows this new wrinkle that was added in J2SE5. In JLS3, package declarations can carry both annotations and a Javadoc comment. The only expected place for these is in a compilation unit named "package-info.java"; this file is expected to contain only a package declaration (i.e., no type decls); note that the name "package-info" is not even a legal identifier. "package-info.java" supercedes the old "package.html", which is less powerful because it cannot express annotations on packages.
The problem reaches even more as reported so far. The annotation that can be defined for a package inside the package-info.java has to be attached to all package declarations inside this packages. Example: package-info.java: /** Test Java Doc // -> AST is missing JavaDoc */ @Deprecated package testJava5; // -> AST shows annotation correctly test.java: package testJava5; // -> AST neighter shows annotation nor JavaDoc public class test { } ---- There is even a different bug at work here: package-info.java: @Deprecated package testJava5; // -> AST does not show annotation -> correct test.java: @Deprecated package testJava5; // -> AST will show annotation -> wrong public class test { }
The last bug shows up as a compile error though (red circled x) in the code editor.
There's no API change for this...
Created attachment 20251 [details] Patch to implement this functionality Note that this patch also cover implementation for bug 86380...
Patch applied in HEAD. Test cases added in JavadocTest_1_? classes + ASTConverterJavadocTest + JavaSearchBugsTests + SelectionJavadocModelTests
Verified for 3.1 M7 using build I20050509-2010 + jdt.core HEAD.