United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4398440 : Reads files whose names are not legal class names when documenting a package

Details
Type:
Bug
Submit Date:
2000-12-15
Status:
Closed
Updated Date:
2014-05-05
Project Name:
JDK
Resolved Date:
2000-12-20
Component:
tools
OS:
generic
Sub-Component:
javadoc(tool)
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.0 (beta)

Related Reports

Sub Tasks

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
                                     
0181-08-12



Hardware and Software, Engineered to Work Together