javax.tools.JavaCompilerTool.getStandardFileManager().list() treats directories as package, if path is relative and if the path is absolute list will not give any thing. Rather it should throw IllegalArgumentException
Test case :
<testcase>
public class T6351767 {
public static void main(String... args) throws Exception {
// Createing necessary things.....
File dir = new File("temp"+args.hashCode());
if (!dir.exists())
dir.mkdir();
if (!dir.isDirectory())
throw new AssertionError("Not a directory " + dir);
File dir1 = new File(dir.getPath()+"/temp"+args.hashCode());
if (!dir1.exists())
dir1.mkdir();
if (!dir1.isDirectory())
throw new AssertionError("Not a directory " + dir);
File dir2 = new File(dir1.getPath()+"/File1.java");
if (!dir2.exists())
dir2.createNewFile();
if (!dir2.isFile())
throw new AssertionError("Not a file" + dir);
// Main Code
try {
JavaCompilerTool compiler = ToolProvider.defaultJavaCompiler();
JavaFileManager jfm = compiler.getStandardFileManager();
for (JavaFileObject jfo : jfm.list(dir1.getPath(), EnumSet.of(Kind.SOURCE))) {
if(jfo.getName().equals("File1.java"))
throw new AssertionError("Getting files from directory :"+jfo);
}
} finally {
dir2.delete();
dir1.delete(); // cleanup
dir.delete();
}
}
}
</testcase>
Tried in SunOS 5.10 sparc Ultra-60
<java-version>
java version "1.6.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b60)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b60, mixed mode)
</java-version>
Test case :
<testcase>
public class T6351767 {
public static void main(String... args) throws Exception {
// Createing necessary things.....
File dir = new File("temp"+args.hashCode());
if (!dir.exists())
dir.mkdir();
if (!dir.isDirectory())
throw new AssertionError("Not a directory " + dir);
File dir1 = new File(dir.getPath()+"/temp"+args.hashCode());
if (!dir1.exists())
dir1.mkdir();
if (!dir1.isDirectory())
throw new AssertionError("Not a directory " + dir);
File dir2 = new File(dir1.getPath()+"/File1.java");
if (!dir2.exists())
dir2.createNewFile();
if (!dir2.isFile())
throw new AssertionError("Not a file" + dir);
// Main Code
try {
JavaCompilerTool compiler = ToolProvider.defaultJavaCompiler();
JavaFileManager jfm = compiler.getStandardFileManager();
for (JavaFileObject jfo : jfm.list(dir1.getPath(), EnumSet.of(Kind.SOURCE))) {
if(jfo.getName().equals("File1.java"))
throw new AssertionError("Getting files from directory :"+jfo);
}
} finally {
dir2.delete();
dir1.delete(); // cleanup
dir.delete();
}
}
}
</testcase>
Tried in SunOS 5.10 sparc Ultra-60
<java-version>
java version "1.6.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b60)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b60, mixed mode)
</java-version>