APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.file

public Class JavacFileManager

extends BaseFileManager
implements StandardJavaFileManager
Class Inheritance
All Implemented Interfaces
javax.tools.StandardJavaFileManager, javax.tools.JavaFileManager, javax.tools.OptionChecker, java.io.Flushable, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.File, .IOException, .UncheckedIOException, java.lang.module.Configuration, .ModuleFinder, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, java.nio.CharBuffer, java.nio.charset.Charset, java.nio.file.FileSystem, .FileSystems, .FileVisitOption, .FileVisitResult, .Files, .InvalidPathException, .LinkOption, .Path, .Paths, .ProviderNotFoundException, .SimpleFileVisitor, java.nio.file.attribute.BasicFileAttributes, java.nio.file.spi.FileSystemProvider, java.util.ArrayList, .Arrays, .Collection, .Collections, .Comparator, .HashMap, .Iterator, .Map, .Objects, .ServiceLoader, .Set, java.util.stream.Stream, java.util.zip.ZipException, javax.lang.model.SourceVersion, javax.tools.FileObject, .JavaFileManager, .JavaFileObject, .StandardJavaFileManager, com.sun.tools.javac.file.RelativePath.RelativeDirectory, .RelativePath.RelativeFile, com.sun.tools.javac.main.Option, com.sun.tools.javac.resources.CompilerProperties.Errors, com.sun.tools.javac.util.Assert, .Context, .Context.Factory, .DefinedBy, .DefinedBy.Api, .List, .ListBuffer, .Options

This class provides access to the source, class and other files used by the compiler and related tools.

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static interface
private class
private class
private static class
protected static enum

Field Summary

Modifier and TypeField and Description
private final Map<Path, JavacFileManager.Container>
private static final boolean
private FSInfo
private JRTIndex
private static final JavacFileManager.Container
private static final Set<FileVisitOption>
private Map<JavaFileManager.Location, List<JavacFileManager.PathAndContainer>>
nonIndexingContainersByLocation

Containers that have no indexing by RelativeDirectory, keyed by Location.

private StandardJavaFileManager.PathFactory
private Map<JavaFileManager.Location, Map<RelativePath.RelativeDirectory, List<JavacFileManager.PathAndContainer>>>
pathsAndContainersByLocationAndRelativeDirectory

We use a two-layered map instead of a map with a complex key because we don't want to reindex the values for every Location+RelativeDirectory pair.

protected JavacFileManager.SortFiles
private static final Set<JavaFileObject.Kind>
protected boolean
Inherited from com.sun.tools.javac.file.BaseFileManager:
autoClosecharsetcontentCachedeferredCloseTimeoutjavacFileManagerOptionslintlocationslogmultiReleaseValueoptions

Constructor Summary

AccessConstructor and Description
public
JavacFileManager(Context context, boolean register, Charset charset)

Create a JavacFileManager using a given context, optionally registering it as the JavaFileManager for that context.

Method Summary

Modifier and TypeMethod and Description
protected void
private static Iterable<File>
asFiles(final Iterable<? extends Path> paths)

Redeclares private: javax.tools.StandardJavaFileManager.asFiles.

public Path
asPath(FileObject file)

Overrides default javax.tools.StandardJavaFileManager.asPath.

Returns the path, if any, underlying this file object (optional operation).

private static Iterable<Path>
asPaths(final Iterable<? extends File> files)

Redeclares private: javax.tools.StandardJavaFileManager.asPaths.

private boolean
caseMapCheck(Path f, RelativePath name)

Hack to make Windows case sensitive.

private void
private void
private void
private void
public void
close()

Implements javax.tools.JavaFileManager.close.

Close the JavaFileManager, releasing resources.

public boolean
contains(JavaFileManager.Location location, FileObject fo)

Overrides default javax.tools.JavaFileManager.contains.

Determines whether or not a given file object is "contained in" a specified location.

public void
flush()

Implements javax.tools.JavaFileManager.flush.

Flush any output resources.

public ClassLoader
getClassLoader(JavaFileManager.Location location)

Implements javax.tools.JavaFileManager.getClassLoader.

Returns a class loader for loading plug-ins from the given package-oriented location.

private Path
pack-priv synchronized JavacFileManager.Container
public FileObject
getFileForInput(JavaFileManager.Location location, String packageName, String relativeName)

Implements javax.tools.JavaFileManager.getFileForInput.

Returns a file object for input representing the specified relative name in the specified package in the given package-oriented location.

private JavaFileObject
public JavaFileObject
public FileObject
getFileForOutput(JavaFileManager.Location location, String packageName, String relativeName, FileObject sibling)

Implements javax.tools.JavaFileManager.getFileForOutput.

Returns a file object for output representing the specified relative name in the specified package in the given location.

private JavaFileObject
public JavaFileObject
getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind)

Implements javax.tools.JavaFileManager.getJavaFileForInput.

Returns a file object for input representing the specified class of the specified kind in the given package-oriented location.

public JavaFileObject
getJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling)

Implements javax.tools.JavaFileManager.getJavaFileForOutput.

Returns a file object for output representing the specified class of the specified kind in the given package-oriented location.

public JavaFileObject
public JavaFileObject
public Iterable<? extends JavaFileObject>
getJavaFileObjects(String... names)

Implements javax.tools.StandardJavaFileManager.getJavaFileObjects.

Returns file objects representing the given file names.

public Iterable<? extends JavaFileObject>
getJavaFileObjects(File... files)

Implements javax.tools.StandardJavaFileManager.getJavaFileObjects.

Returns file objects representing the given files.

public Iterable<? extends JavaFileObject>
getJavaFileObjects(Path... paths)

Overrides default javax.tools.StandardJavaFileManager.getJavaFileObjects.

Returns file objects representing the given paths.

public Iterable<? extends JavaFileObject>
getJavaFileObjectsFromFiles(Iterable<? extends File> files)

Implements javax.tools.StandardJavaFileManager.getJavaFileObjectsFromFiles.

Returns file objects representing the given files.

public Iterable<? extends JavaFileObject>
getJavaFileObjectsFromPaths(Collection<? extends Path> paths)

Overrides default javax.tools.StandardJavaFileManager.getJavaFileObjectsFromPaths.

Returns file objects representing the given paths.

public Iterable<? extends JavaFileObject>
getJavaFileObjectsFromStrings(Iterable<String> names)

Implements javax.tools.StandardJavaFileManager.getJavaFileObjectsFromStrings.

Returns file objects representing the given file names.

private synchronized JRTIndex
public Iterable<? extends File>
getLocation(JavaFileManager.Location location)

Implements javax.tools.StandardJavaFileManager.getLocation.

Returns the search path associated with the given location.

public Collection<? extends Path>
getLocationAsPaths(JavaFileManager.Location location)

Overrides default javax.tools.StandardJavaFileManager.getLocationAsPaths.

Returns the search path associated with the given location.

public JavaFileManager.Location
getLocationForModule(JavaFileManager.Location location, String moduleName)

Overrides default javax.tools.JavaFileManager.getLocationForModule.

Gets a location for a named module within a location, which may be either a module-oriented location or an output location.

public JavaFileManager.Location
getLocationForModule(JavaFileManager.Location location, JavaFileObject fo)

Overrides default javax.tools.JavaFileManager.getLocationForModule.

Gets a location for the module containing a specific file to be found within a location, which may be either a module-oriented location or an output location.

public static String

Returns:

a string to include in a compiler diagnostic
getMessage
(IOException
an IOException
e
)

Get a detail message from an IOException.

private Path
getPath(String first, String... more)

public static String

Returns:

a relative URI
getRelativeName
(File
a relative file name
file
)

Converts a relative file name to a relative URI.

public <S> ServiceLoader<S>
getServiceLoader(JavaFileManager.Location location, Class<S> service)

Overrides default javax.tools.JavaFileManager.getServiceLoader.

Get a service loader for a specific service class from a given location.

private Path
public boolean
handleOption(Option option, String value)

Overrides com.sun.tools.javac.file.BaseFileManager.handleOption.

Common back end for OptionHelper handleFileManagerOption.

protected boolean
public boolean
hasLocation(JavaFileManager.Location location)

Implements javax.tools.JavaFileManager.hasLocation.

Determines if a location is known to this file manager.

private Map<RelativePath.RelativeDirectory, List<JavacFileManager.PathAndContainer>>
public String
inferBinaryName(JavaFileManager.Location location, JavaFileObject file)

Implements javax.tools.JavaFileManager.inferBinaryName.

Infers a binary name of a file object based on a package-oriented location.

public String
inferModuleName(JavaFileManager.Location location)

Overrides default javax.tools.JavaFileManager.inferModuleName.

Infer the name of the module from its location, as returned by getLocationForModule or listModuleLocations.

protected static boolean
isRelativeUri(URI uri)

Enforces the specification of a "relative" name as used in getFileForInput.

protected static boolean
public boolean
isSameFile(FileObject a, FileObject b)

Implements javax.tools.StandardJavaFileManager.isSameFile, javax.tools.JavaFileManager.isSameFile.

Compares two file objects and return true if they represent the same canonical file, zip file entry, or entry in any file system based container.

public boolean
private boolean
isValidFile(String s, Set<JavaFileObject.Kind> fileKinds)

container is a directory, a zip file, or a non-existent path.

private static boolean
public Iterable<JavaFileObject>
list(JavaFileManager.Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse)

Implements javax.tools.JavaFileManager.list.

Lists all file objects matching the given criteria in the given package-oriented location.

public Iterable<Set<JavaFileManager.Location>>
listLocationsForModules(JavaFileManager.Location location)

Overrides default javax.tools.JavaFileManager.listLocationsForModules.

Lists the locations for all the modules in a module-oriented location or an output location.

private List<JavacFileManager.PathAndContainer>
private List<JavacFileManager.PathAndContainer>
pathsAndContainers(JavaFileManager.Location location)

For each path of the location, compute the corresponding Container.

public static void
preRegister(Context context)

Register a Context.Factory to create a JavacFileManager.

private static void
printAscii(String format, Object... args)

public void
setContext(Context context)

Overrides com.sun.tools.javac.file.BaseFileManager.setContext.

Set the context for JavacFileManager.

public void
setLocation(JavaFileManager.Location location, Iterable<? extends File> searchpath)

Implements javax.tools.StandardJavaFileManager.setLocation.

Associates the given search path with the given location.

public void
setLocationForModule(JavaFileManager.Location location, String moduleName, Collection<? extends Path> paths)

Overrides default javax.tools.StandardJavaFileManager.setLocationForModule.

Associates the given search path with the given module and location, which must be a module-oriented or output location.

public void
setLocationFromPaths(JavaFileManager.Location location, Collection<? extends Path> searchpath)

Overrides default javax.tools.StandardJavaFileManager.setLocationFromPaths.

Associates the given search path with the given location.

public void
setPathFactory(StandardJavaFileManager.PathFactory f)

Overrides default javax.tools.StandardJavaFileManager.setPathFactory.

Specify a factory that can be used to generate a path from a string, or series of strings.

public void
setSymbolFileEnabled(boolean b)

Set whether or not to use ct.sym as an alternate to the current runtime.

public static void
testName(String name, boolean isValidPackageName, boolean isValidClassName)

public static char[]
private static void
private static void
Inherited from com.sun.tools.javac.file.BaseFileManager:
cacheclearcreateLocationsdecodedeferredCloseflushCachegetCachedContentgetClassLoadergetDecodergetEncodingNamegetKindgetKindhandleOptionhandleOptionsisDefaultBootClassPathisDefaultSystemModulesPathisSupportedOptionmakeByteBuffernewOutputToPathnullChecknullCheckrecycleByteBufferresetOutputFilesWrittenupdateLastUsedTime