JDK-4398440 : Reads files whose names are not legal class names when documenting a package
  • Type: Bug
  • Status: Closed
  • Resolution: Fixed
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Priority: P3
  • Affected Version: 1.4.0
  • OS: generic
  • CPU: generic
  • Submit Date: 2000-12-15
  • Updated Date: 2014-05-05
  • Resolved Date: 2000-12-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Description
Given the command

    % javadoc -sourcepath /foo/bar com.sun.baz

Javadoc will try to parse every file in the directory /foo/bar/com/sun/baz
whose name ends with ".java", regardless of whether the name, stripped of that
suffix, is actually a legal class name.  This causes problems with files that
are used as templates for source files that are generated during the build.
Such files are typically named using characters such as '-' in order to
distinguish them from ordinary class files, and the contents of such files
are not quite legal Java code.

-- mr@eng 2000/12/15

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: merlin-beta INTEGRATED IN: merlin-beta VERIFIED IN: merlin-beta3
2004-06-14

SUGGESTED FIX *** /tmp/geta19656 Thu Dec 14 21:10:56 2000 --- src/share/classes/com/sun/tools/javadoc/Start.java Thu Dec 14 20:49:58 2000 *************** *** 371,376 **** --- 371,386 ---- return new RootDocImpl(env, userClasses, userPkgs, options); } + private static boolean legalClassName(String nm) { + if (!Character.isJavaIdentifierStart(nm.charAt(0))) + return false; + int n = nm.length(); + for (int i = 1; i < n; i++) + if (!Character.isJavaIdentifierPart(nm.charAt(i))) + return false; + return true; + } + private void parseSourcePackage(Env env, String name) throws IOException { Identifier id = Identifier.lookup(name); // Check to see if the name refers to an entire *************** *** 379,390 **** boolean hasFiles = false; if (pkg.exists()) { Enumeration sourceEnum = pkg.getSourceFiles(); while (sourceEnum.hasMoreElements()) { if (!hasFiles) { docenv.notice("main.Loading_source_files_for_package", name); hasFiles = true; } ! env.parseFile((ClassFile)sourceEnum.nextElement()); } } if (!hasFiles) { --- 389,407 ---- boolean hasFiles = false; if (pkg.exists()) { Enumeration sourceEnum = pkg.getSourceFiles(); + nextFile: while (sourceEnum.hasMoreElements()) { if (!hasFiles) { docenv.notice("main.Loading_source_files_for_package", name); hasFiles = true; } ! ClassFile cf = (ClassFile)sourceEnum.nextElement(); ! String nm = cf.getName(); ! if (nm.endsWith(".java")) ! nm = nm.substring(0, nm.length() - 5); ! if (!legalClassName(nm)) ! continue; ! env.parseFile(cf); } } if (!hasFiles) {
2004-06-11

EVALUATION Fixed. -- mr@eng 2000/12/15 Pasting Doug Kramer's Notes. > > > Verified using /home/dkramer/javadoc/1.4/run-4398440-legalname ###@###.### 2001-11-07
181-08-12 0