Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6340549

javax.tools.JavaCompilerTool.getStandardFileManager().list() includes directories

XMLWordPrintable

    • b105
    • generic
    • generic
    • Verified

      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>

            jjg Jonathan Gibbons
            savadhansunw Seetharama Avadhanam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: