JDK-6340549 : javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-10-22
  • Updated: 2016-03-23
  • Resolved: 2011-03-07
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 Availability Release.

To download the current JDK release, click here.
JDK 7
7 b105Fixed
Related Reports
Relates :  
Description
javax.tools.JavaCompilerTool.getStandardFileManager().list() includes
directories, however, the specification mentions that the framework
has no concept of directories.

The following test cases demonstrates the problem:

--- begin: T6340549.java ---
import javax.tools.*;
import java.util.*;
import java.io.*;

import static javax.tools.JavaFileObject.Kind;

public class T6340549 {
    public static void main(String... args) throws Exception {

	// Ensure a directory exits
	File dir = new File("temp" + args.hashCode());
	if (!dir.exists())
	    dir.mkdir();
	if (!dir.isDirectory())
	    throw new AssertionError("Not a directory " + dir);

	try {
	    JavaCompilerTool compiler = ToolProvider.defaultJavaCompiler();
	    JavaFileManager jfm = compiler.getStandardFileManager();

	    for (JavaFileObject jfo : jfm.list(".", EnumSet.of(Kind.OTHER))) {
		if (new File(jfo.getPath()).isDirectory()) {
		    throw new AssertionError("Found directory: " + jfo);
		}
	    }
	} finally {
	    dir.delete(); // cleanup
	}

    }
}
--- end: T6340549.java ---

Tried in WINDOWS 2K with JDK-build 1.6.0-auto-294
<java-version>
java version "1.6.0-auto"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-auto-294)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b57, mixed mode)
<\java-version>

Comments
EVALUATION Failure not reproducible; bug kept open to track adding test to repo.
27-07-2010