1.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Tue Oct 25 15:40:34 2011 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Tue Oct 25 10:48:05 2011 -0700 1.3 @@ -54,17 +54,14 @@ 1.4 import javax.tools.JavaFileObject; 1.5 import javax.tools.StandardJavaFileManager; 1.6 1.7 -import com.sun.tools.javac.code.Lint; 1.8 import com.sun.tools.javac.file.RelativePath.RelativeFile; 1.9 import com.sun.tools.javac.file.RelativePath.RelativeDirectory; 1.10 -import com.sun.tools.javac.main.OptionName; 1.11 import com.sun.tools.javac.util.BaseFileManager; 1.12 import com.sun.tools.javac.util.Context; 1.13 import com.sun.tools.javac.util.List; 1.14 import com.sun.tools.javac.util.ListBuffer; 1.15 1.16 import static javax.tools.StandardLocation.*; 1.17 -import static com.sun.tools.javac.main.OptionName.*; 1.18 1.19 /** 1.20 * This class provides access to the source, class and other files 1.21 @@ -89,23 +86,9 @@ 1.22 private boolean contextUseOptimizedZip; 1.23 private ZipFileIndexCache zipFileIndexCache; 1.24 1.25 - private final File uninited = new File("U N I N I T E D"); 1.26 - 1.27 private final Set<JavaFileObject.Kind> sourceOrClass = 1.28 EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS); 1.29 1.30 - /** The standard output directory, primarily used for classes. 1.31 - * Initialized by the "-d" option. 1.32 - * If classOutDir = null, files are written into same directory as the sources 1.33 - * they were generated from. 1.34 - */ 1.35 - private File classOutDir = uninited; 1.36 - 1.37 - /** The output directory, used when generating sources while processing annotations. 1.38 - * Initialized by the "-s" option. 1.39 - */ 1.40 - private File sourceOutDir = uninited; 1.41 - 1.42 protected boolean mmappedIO; 1.43 protected boolean ignoreSymbolFile; 1.44 1.45 @@ -169,7 +152,7 @@ 1.46 1.47 @Override 1.48 public boolean isDefaultBootClassPath() { 1.49 - return searchPaths.isDefaultBootClassPath(); 1.50 + return locations.isDefaultBootClassPath(); 1.51 } 1.52 1.53 public JavaFileObject getFileForInput(String name) { 1.54 @@ -483,7 +466,7 @@ 1.55 */ 1.56 private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException { 1.57 File origZipFileName = zipFileName; 1.58 - if (!ignoreSymbolFile && searchPaths.isDefaultBootClassPathRtJar(zipFileName)) { 1.59 + if (!ignoreSymbolFile && locations.isDefaultBootClassPathRtJar(zipFileName)) { 1.60 File file = zipFileName.getParentFile().getParentFile(); // ${java.home} 1.61 if (new File(file.getName()).equals(new File("jre"))) 1.62 file = file.getParentFile(); 1.63 @@ -770,7 +753,7 @@ 1.64 } else if (location == SOURCE_OUTPUT) { 1.65 dir = (getSourceOutDir() != null ? getSourceOutDir() : getClassOutDir()); 1.66 } else { 1.67 - Iterable<? extends File> path = searchPaths.getPathForLocation(location); 1.68 + Iterable<? extends File> path = locations.getLocation(location); 1.69 dir = null; 1.70 for (File f: path) { 1.71 dir = f; 1.72 @@ -805,64 +788,20 @@ 1.73 throws IOException 1.74 { 1.75 nullCheck(location); 1.76 - searchPaths.lazy(); 1.77 - 1.78 - final File dir = location.isOutputLocation() ? getOutputDirectory(path) : null; 1.79 - 1.80 - if (location == CLASS_OUTPUT) 1.81 - classOutDir = getOutputLocation(dir, D); 1.82 - else if (location == SOURCE_OUTPUT) 1.83 - sourceOutDir = getOutputLocation(dir, S); 1.84 - else 1.85 - searchPaths.setPathForLocation(location, path); 1.86 - } 1.87 - // where 1.88 - private File getOutputDirectory(Iterable<? extends File> path) throws IOException { 1.89 - if (path == null) 1.90 - return null; 1.91 - Iterator<? extends File> pathIter = path.iterator(); 1.92 - if (!pathIter.hasNext()) 1.93 - throw new IllegalArgumentException("empty path for directory"); 1.94 - File dir = pathIter.next(); 1.95 - if (pathIter.hasNext()) 1.96 - throw new IllegalArgumentException("path too long for directory"); 1.97 - if (!dir.exists()) 1.98 - throw new FileNotFoundException(dir + ": does not exist"); 1.99 - else if (!dir.isDirectory()) 1.100 - throw new IOException(dir + ": not a directory"); 1.101 - return dir; 1.102 - } 1.103 - 1.104 - private File getOutputLocation(File dir, OptionName defaultOptionName) { 1.105 - if (dir != null) 1.106 - return dir; 1.107 - String arg = options.get(defaultOptionName); 1.108 - if (arg == null) 1.109 - return null; 1.110 - return new File(arg); 1.111 + locations.setLocation(location, path); 1.112 } 1.113 1.114 public Iterable<? extends File> getLocation(Location location) { 1.115 nullCheck(location); 1.116 - searchPaths.lazy(); 1.117 - if (location == CLASS_OUTPUT) { 1.118 - return (getClassOutDir() == null ? null : List.of(getClassOutDir())); 1.119 - } else if (location == SOURCE_OUTPUT) { 1.120 - return (getSourceOutDir() == null ? null : List.of(getSourceOutDir())); 1.121 - } else 1.122 - return searchPaths.getPathForLocation(location); 1.123 + return locations.getLocation(location); 1.124 } 1.125 1.126 private File getClassOutDir() { 1.127 - if (classOutDir == uninited) 1.128 - classOutDir = getOutputLocation(null, D); 1.129 - return classOutDir; 1.130 + return locations.getOutputLocation(CLASS_OUTPUT); 1.131 } 1.132 1.133 private File getSourceOutDir() { 1.134 - if (sourceOutDir == uninited) 1.135 - sourceOutDir = getOutputLocation(null, S); 1.136 - return sourceOutDir; 1.137 + return locations.getOutputLocation(SOURCE_OUTPUT); 1.138 } 1.139 1.140 /**