/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// NOTE the imports carefully for this compilation unit.
//
// Path: java.nio.file.Path -- the new NIO type for which this file manager exists
//
// Paths: com.sun.tools.javac.file.Paths -- legacy javac type for handling path options
// The other Paths (java.nio.file.Paths) is not used
// NOTE this and related classes depend on new API in JDK 7.
// This requires special handling while bootstrapping the JDK build,
// when these classes might not yet have been compiled. To workaround
// this, the build arranges to make stubs of these classes available
// when compiling this and related classes. The set of stub files
// is specified in make/build.properties.
/**
* Implementation of PathFileManager: a JavaFileManager based on the use
* of java.nio.file.Path.
*
* <p>Just as a Path is somewhat analagous to a File, so too is this
* JavacPathFileManager analogous to JavacFileManager, as it relates to the
* support of FileObjects based on File objects (i.e. just RegularFileObject,
* not ZipFileObject and its variants.)
*
* <p>The default values for the standard locations supported by this file
* manager are the same as the default values provided by JavacFileManager --
* i.e. as determined by the javac.file.Paths class. To override these values,
* call {@link #setLocation}.
*
* <p>To reduce confusion with Path objects, the locations such as "class path",
* "source path", etc, are generically referred to here as "search paths".
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
/**
* Create a JavacPathFileManager using a given context, optionally registering
* it as the JavaFileManager for that context.
*/
super(charset);
if (register)
}
/**
* Set the context for JavacPathFileManager.
*/
super.setContext(context);
}
if (defaultFileSystem == null)
return defaultFileSystem;
}
}
}
}
return null;
try {
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
}
}
public boolean isDefaultBootClassPath() {
return searchPaths.isDefaultBootClassPath();
}
// <editor-fold defaultstate="collapsed" desc="Location handling">
}
}
return path;
}
}
throws IOException
{
if (searchPath == null) {
} else {
if (location.isOutputLocation())
for (Path p: searchPath)
}
}
throw new IllegalArgumentException("empty path for directory");
throw new IllegalArgumentException("path too long for directory");
if (!isDirectory(path))
}
if (locn instanceof StandardLocation) {
switch ((StandardLocation) locn) {
case CLASS_PATH:
break;
case PLATFORM_CLASS_PATH:
break;
case SOURCE_PATH:
break;
case CLASS_OUTPUT: {
break;
}
case SOURCE_OUTPUT: {
break;
}
}
}
}
}
private void lazyInitSearchPaths() {
if (!inited) {
inited = true;
}
}
// where
private boolean inited = false;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="FileObject handling">
if (!(fo instanceof PathFileObject))
throw new IllegalArgumentException();
}
nullCheck(a);
nullCheck(b);
if (!(a instanceof PathFileObject))
throw new IllegalArgumentException("Not supported: " + a);
if (!(b instanceof PathFileObject))
throw new IllegalArgumentException("Not supported: " + b);
}
throws IOException {
// validatePackageName(packageName);
}
throws IOException {
return;
if (isDirectory(path))
else {
return;
}
return;
/* Alternate impl of list, superceded by use of Files.walkFileTree */
// Deque<Path> queue = new LinkedList<Path>();
// queue.add(packageDir);
//
// Path dir;
// while ((dir = queue.poll()) != null) {
// DirectoryStream<Path> ds = dir.newDirectoryStream();
// try {
// for (Path p: ds) {
// String name = p.getFileName().toString();
// if (isDirectory(p)) {
// if (recurse && SourceVersion.isIdentifier(name)) {
// queue.add(p);
// }
// } else {
// if (kinds.contains(getKind(name))) {
// JavaFileObject fe =
// PathFileObject.createDirectoryPathFileObject(this, p, pathDir);
// results.append(fe);
// }
// }
// }
// } finally {
// ds.close();
// }
// }
new SimpleFileVisitor<Path>() {
return FileVisitResult.CONTINUE;
else
return FileVisitResult.SKIP_SUBTREE;
}
}
return FileVisitResult.CONTINUE;
}
});
}
if (paths instanceof Collection<?>)
else
return result;
}
}
}
}
throws IOException {
if (isDirectory(p)) {
return PathFileObject.createDirectoryPathFileObject(this, f, p);
} else {
}
}
}
return null;
}
}
throws IOException {
}
if (location == CLASS_OUTPUT) {
}
return PathFileObject.createSiblingPathFileObject(this,
} else if (location == SOURCE_OUTPUT) {
}
}
} else {
}
}
// Need to match the path semantics of list(location, ...)
return null;
}
if (!(fo instanceof PathFileObject))
}
}
return fs;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Utility methods">
}
}
}
return attrs.isDirectory();
}
}
}
// </editor-fold>
}