APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.jrtfs

pack-priv Class JrtFileSystem

extends FileSystem
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, .OutputStream, java.nio.ByteBuffer, java.nio.channels.Channels, .FileChannel, .NonWritableChannelException, .ReadableByteChannel, .SeekableByteChannel, java.nio.file.ClosedFileSystemException, .CopyOption, .DirectoryStream, .FileStore, .FileSystem, .FileSystemException, .InvalidPathException, .LinkOption, .NoSuchFileException, .NotDirectoryException, .OpenOption, .Path, .PathMatcher, .ReadOnlyFileSystemException, .StandardOpenOption, .WatchService, java.nio.file.attribute.FileAttribute, .FileTime, .UserPrincipalLookupService, java.nio.file.spi.FileSystemProvider, java.util.Arrays, .Collections, .HashSet, .Iterator, .Map, .Objects, .Set, java.util.regex.Pattern, jdk.internal.jimage.ImageReader.Node, .PreviewMode

jrt file system implementation built on System jimage files.

Implementation Note

This class needs to maintain JDK 8 source compatibility. It is used internally in the JDK to implement jimage/jrtfs access, but also compiled and delivered as part of the jrtfs.jar to support access to the jimage file provided by the shipped JDK by tools running on JDK 8.

Field Summary

Modifier and TypeField and Description
private SystemImage
private volatile boolean
private volatile boolean
private final JrtFileSystemProvider
private final JrtPath
private static final Set<String>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv ImageReader.Node
pack-priv static void
checkOptions(Set<? extends OpenOption> options)

pack-priv synchronized void
public void
close()

Implements abstract java.nio.file.FileSystem.close.

Implements java.io.Closeable.close.

Closes this file system.

pack-priv final void
copyFile(boolean deletesrc, JrtPath srcPath, JrtPath dstPath, CopyOption... options)

pack-priv final void
createDirectory(JrtPath jrtPath, FileAttribute<?>... attrs)

pack-priv final void
deleteFile(JrtPath jrtPath, boolean failIfNotExists)

pack-priv final void
pack-priv boolean
pack-priv JrtFileAttributes
pack-priv byte[]
pack-priv final JrtFileStore
public final Iterable<FileStore>
getFileStores()

Implements abstract java.nio.file.FileSystem.getFileStores.

Returns an object to iterate over the underlying file stores.

public JrtPath
getPath(String first, String... more)

Implements abstract java.nio.file.FileSystem.getPath.

Converts a path string, or a sequence of strings that when joined form a path string, to a Path.

public PathMatcher
getPathMatcher(String syntaxAndInput)

Implements abstract java.nio.file.FileSystem.getPathMatcher.

Returns a PathMatcher that performs match operations on the String representation of Path objects by interpreting a given pattern.

public Iterable<Path>
getRootDirectories()

Implements abstract java.nio.file.FileSystem.getRootDirectories.

Returns an object to iterate over the paths of the root directories.

pack-priv final JrtPath
public final String
getSeparator()

Implements abstract java.nio.file.FileSystem.getSeparator.

Returns the name separator, represented as a string.

public final UserPrincipalLookupService
getUserPrincipalLookupService()

Implements abstract java.nio.file.FileSystem.getUserPrincipalLookupService.

Returns the UserPrincipalLookupService for this file system (optional operation).

pack-priv boolean
isDirectory(JrtPath path, boolean resolveLinks)

public boolean
isOpen()

Implements abstract java.nio.file.FileSystem.isOpen.

Tells whether or not this file system is open.

public final boolean
isReadOnly()

Implements abstract java.nio.file.FileSystem.isReadOnly.

Tells whether or not this file system allows only read-only access to its file stores.

pack-priv boolean
isSameFile(JrtPath path1, JrtPath path2)

pack-priv Iterator<Path>

Returns:

iterator for child paths of the given directory path
iteratorOf
(JrtPath
name of the directory whose content is listed
path
,
DirectoryStream.Filter<? super Path> filter)

returns the list of child paths of the given directory "path"

private ImageReader.Node
lookup(String path)

private ImageReader.Node
pack-priv final SeekableByteChannel
newByteChannel(JrtPath path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)

pack-priv final FileChannel
newFileChannel(JrtPath path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)

pack-priv final InputStream
pack-priv final OutputStream
newOutputStream(JrtPath jrtPath, OpenOption... options)

public final WatchService
newWatchService()

Implements abstract java.nio.file.FileSystem.newWatchService.

Constructs a new WatchService (optional operation).

public FileSystemProvider
provider()

Implements abstract java.nio.file.FileSystem.provider.

Returns the provider that created this file system.

pack-priv static ReadOnlyFileSystemException
pack-priv final void
setTimes(JrtPath jrtPath, FileTime mtime, FileTime atime, FileTime ctime)

public final Set<String>
supportedFileAttributeViews()

Implements abstract java.nio.file.FileSystem.supportedFileAttributeViews.

Returns the set of the names of the file attribute views supported by this FileSystem.

pack-priv JrtPath
toRealPath(JrtPath path, LinkOption... options)

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Field Detail

imageback to summary
private SystemImage image
isClosableback to summary
private volatile boolean isClosable
isOpenback to summary
private volatile boolean isOpen
providerback to summary
private final JrtFileSystemProvider provider
rootPathback to summary
private final JrtPath rootPath
supportedFileAttributeViewsback to summary
private static final Set<String> supportedFileAttributeViews

Constructor Detail

JrtFileSystemback to summary
pack-priv JrtFileSystem(JrtFileSystemProvider provider, Map<String, ?> env) throws IOException

Method Detail

checkNodeback to summary
pack-priv ImageReader.Node checkNode(JrtPath path) throws IOException
checkOptionsback to summary
pack-priv static void checkOptions(Set<? extends OpenOption> options)
cleanupback to summary
pack-priv synchronized void cleanup() throws IOException
closeback to summary
public void close() throws IOException

Implements abstract java.nio.file.FileSystem.close.

Implements java.io.Closeable.close.

Doc from java.nio.file.FileSystem.close.

Closes this file system.

After a file system is closed then all subsequent access to the file system, either by methods defined by this class or on objects associated with this file system, throw ClosedFileSystemException. If the file system is already closed then invoking this method has no effect.

Closing a file system will close all open channels, directory-streams, watch-service, and other closeable objects associated with this file system. The default file system cannot be closed.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
copyFileback to summary
pack-priv final void copyFile(boolean deletesrc, JrtPath srcPath, JrtPath dstPath, CopyOption... options) throws IOException
createDirectoryback to summary
pack-priv final void createDirectory(JrtPath jrtPath, FileAttribute<?>... attrs) throws IOException
deleteFileback to summary
pack-priv final void deleteFile(JrtPath jrtPath, boolean failIfNotExists) throws IOException
ensureOpenback to summary
pack-priv final void ensureOpen() throws IOException
existsback to summary
pack-priv boolean exists(JrtPath path) throws IOException
getFileAttributesback to summary
pack-priv JrtFileAttributes getFileAttributes(JrtPath path, LinkOption... options) throws IOException
getFileContentback to summary
pack-priv byte[] getFileContent(JrtPath path) throws IOException
getFileStoreback to summary
pack-priv final JrtFileStore getFileStore(JrtPath path)
getFileStoresback to summary
public final Iterable<FileStore> getFileStores()

Implements abstract java.nio.file.FileSystem.getFileStores.

Doc from java.nio.file.FileSystem.getFileStores.

Returns an object to iterate over the underlying file stores.

The elements of the returned iterator are the FileStores for this file system. The order of the elements is not defined and the file stores may change during the lifetime of the Java virtual machine. When an I/O error occurs, perhaps because a file store is not accessible, then it is not returned by the iterator.

Usage Example: Suppose we want to print the space usage for all file stores:

for (FileStore store: FileSystems.getDefault().getFileStores()) { long total = store.getTotalSpace() / 1024; long used = (store.getTotalSpace() - store.getUnallocatedSpace()) / 1024; long avail = store.getUsableSpace() / 1024; System.out.format("%-20s %12d %12d %12d%n", store, total, used, avail); }
for (FileStore store: FileSystems.getDefault().getFileStores()) {
    long total = store.getTotalSpace() / 1024;
    long used = (store.getTotalSpace() - store.getUnallocatedSpace()) / 1024;
    long avail = store.getUsableSpace() / 1024;
    System.out.format("%-20s %12d %12d %12d%n", store, total, used, avail);
}
Annotations
@Override
getPathback to summary
public JrtPath getPath(String first, String... more)

Implements abstract java.nio.file.FileSystem.getPath.

Doc from java.nio.file.FileSystem.getPath.

Converts a path string, or a sequence of strings that when joined form a path string, to a Path. If more does not specify any elements then the value of the first parameter is the path string to convert. If more specifies one or more elements then each non-empty string, including first, is considered to be a sequence of name elements (see Path) and is joined to form a path string. The details as to how the Strings are joined is provider specific but typically they will be joined using the name-separator as the separator. For example, if the name separator is "/" and getPath("/foo","bar","gus") is invoked, then the path string "/foo/bar/gus" is converted to a Path. A Path representing an empty path is returned if first is the empty string and more does not contain any non-empty strings.

The parsing and conversion to a path object is inherently implementation dependent. In the simplest case, the path string is rejected, and InvalidPathException thrown, if the path string contains characters that cannot be converted to characters that are legal to the file store. For example, on UNIX systems, the NUL (\u0000) character is not allowed to be present in a path. An implementation may choose to reject path strings that contain names that are longer than those allowed by any file store, and where an implementation supports a complex path syntax, it may choose to reject path strings that are badly formed.

In the case of the default provider, path strings are parsed based on the definition of paths at the platform or virtual file system level. For example, an operating system may not allow specific characters to be present in a file name, but a specific underlying file store may impose different or additional restrictions on the set of legal characters.

This method throws InvalidPathException when the path string cannot be converted to a path. Where possible, and where applicable, the exception is created with an index value indicating the first position in the path parameter that caused the path string to be rejected.

Annotations
@Override
getPathMatcherback to summary
public PathMatcher getPathMatcher(String syntaxAndInput)

Implements abstract java.nio.file.FileSystem.getPathMatcher.

Doc from java.nio.file.FileSystem.getPathMatcher.

Returns a PathMatcher that performs match operations on the String representation of Path objects by interpreting a given pattern. The syntaxAndPattern parameter identifies the syntax and the pattern and takes the form:

syntax:pattern
where syntax is the non-empty name of the syntax, pattern is a possibly-empty pattern string, and ':' stands for itself.

A FileSystem implementation supports the "glob" and "regex" syntaxes, and may support others. The value of the syntax component is compared without regard to case.

When the syntax is "glob" then the String representation of the path is matched using a limited pattern language that resembles regular expressions but with a simpler syntax. For example:

Pattern Language
Example Description
*.java Matches a path that represents a file name ending in .java
*.* Matches file names containing a dot
*.{java,class} Matches file names ending with .java or .class
foo.? Matches file names starting with foo. and a single character extension
/home/*/* Matches /home/gus/data on UNIX platforms
/home/** Matches /home/gus and /home/gus/data on UNIX platforms
C:\\* Matches C:\foo and C:\bar on the Windows platform (note that the backslash is escaped; as a string literal in the Java Language the pattern would be "C:\\\\*")

The following rules are used to interpret glob patterns:

  • The * character matches zero or more characters of a name component without crossing directory boundaries.

  • The ** characters matches zero or more characters crossing directory boundaries.

  • The ? character matches exactly one character of a name component.

  • The backslash character (\) is used to escape characters that would otherwise be interpreted as special characters. The expression \\ matches a single backslash and "\{" matches a left brace for example.

  • The [ ] characters are a bracket expression that match a single character of a name component out of a set of characters. For example, [abc] matches "a", "b", or "c". The hyphen (-) may be used to specify a range so [a-z] specifies a range that matches from "a" to "z" (inclusive). These forms can be mixed so [abce-g] matches "a", "b", "c", "e", "f" or "g". If the character after the [ is a ! then it is used for negation so [!a-c] matches any character except "a", "b", or "c".

    Within a bracket expression the *, ? and \ characters match themselves. The (-) character matches itself if it is the first character within the brackets, or the first character after the ! if negating.

  • The { } characters are a group of subpatterns, where the group matches if any subpattern in the group matches. The "," character is used to separate the subpatterns. Groups cannot be nested.

  • Leading period/dot characters in file name are treated as regular characters in match operations. For example, the "*" glob pattern matches file name ".login". The Files#isHidden method may be used to test whether a file is considered hidden.

  • All other characters match themselves in an implementation dependent manner. This includes characters representing any name-separators.

  • The matching of root components is highly implementation-dependent and is not specified.

When the syntax is "regex" then the pattern component is a regular expression as defined by the java.util.regex.Pattern class.

For both the glob and regex syntaxes, the matching details, such as whether the matching is case sensitive, are implementation-dependent and therefore not specified.

Annotations
@Override
getRootDirectoriesback to summary
public Iterable<Path> getRootDirectories()

Implements abstract java.nio.file.FileSystem.getRootDirectories.

Doc from java.nio.file.FileSystem.getRootDirectories.

Returns an object to iterate over the paths of the root directories.

A file system provides access to a file store that may be composed of a number of distinct file hierarchies, each with its own top-level root directory. Each element in the returned iterator corresponds to the root directory of a distinct file hierarchy. The order of the elements is not defined. The file hierarchies may change during the lifetime of the ava virtual machine. For example, in some implementations, the insertion of removable media may result in the creation of a new file hierarchy with its own top-level directory. There is no guarantee that a root directory can be accessed.

Annotations
@Override
getRootPathback to summary
pack-priv final JrtPath getRootPath()
getSeparatorback to summary
public final String getSeparator()

Implements abstract java.nio.file.FileSystem.getSeparator.

Doc from java.nio.file.FileSystem.getSeparator.

Returns the name separator, represented as a string.

The name separator is used to separate names in a path string. An implementation may support multiple name separators in which case this method returns an implementation specific default name separator. This separator is used when creating path strings by invoking the toString() method.

In the case of the default provider, this method returns the same separator as java.io.File#separator.

Annotations
@Override
getUserPrincipalLookupServiceback to summary
public final UserPrincipalLookupService getUserPrincipalLookupService()

Implements abstract java.nio.file.FileSystem.getUserPrincipalLookupService.

Doc from java.nio.file.FileSystem.getUserPrincipalLookupService.

Returns the UserPrincipalLookupService for this file system (optional operation). The resulting lookup service may be used to lookup user or group names.

Usage Example: Suppose we want to make "joe" the owner of a file:

UserPrincipalLookupService lookupService = FileSystems.getDefault().getUserPrincipalLookupService(); Files.setOwner(path, lookupService.lookupPrincipalByName("joe"));
UserPrincipalLookupService lookupService = FileSystems.getDefault().getUserPrincipalLookupService();
Files.setOwner(path, lookupService.lookupPrincipalByName("joe"));
Annotations
@Override
isDirectoryback to summary
pack-priv boolean isDirectory(JrtPath path, boolean resolveLinks) throws IOException
isOpenback to summary
public boolean isOpen()

Implements abstract java.nio.file.FileSystem.isOpen.

Doc from java.nio.file.FileSystem.isOpen.

Tells whether or not this file system is open.

File systems created by the default provider are always open.

Annotations
@Override
isReadOnlyback to summary
public final boolean isReadOnly()

Implements abstract java.nio.file.FileSystem.isReadOnly.

Doc from java.nio.file.FileSystem.isReadOnly.

Tells whether or not this file system allows only read-only access to its file stores.

Annotations
@Override
isSameFileback to summary
pack-priv boolean isSameFile(JrtPath path1, JrtPath path2) throws IOException
iteratorOfback to summary
pack-priv Iterator<Path> iteratorOf(JrtPath path, DirectoryStream.Filter<? super Path> filter) throws IOException

returns the list of child paths of the given directory "path"

Parameters
path:JrtPath

name of the directory whose content is listed

Returns:Iterator<Path>

iterator for child paths of the given directory path

lookupback to summary
private ImageReader.Node lookup(String path)
lookupSymbolicback to summary
private ImageReader.Node lookupSymbolic(String path)
newByteChannelback to summary
pack-priv final SeekableByteChannel newByteChannel(JrtPath path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
newFileChannelback to summary
pack-priv final FileChannel newFileChannel(JrtPath path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
newInputStreamback to summary
pack-priv final InputStream newInputStream(JrtPath path) throws IOException
newOutputStreamback to summary
pack-priv final OutputStream newOutputStream(JrtPath jrtPath, OpenOption... options) throws IOException
newWatchServiceback to summary
public final WatchService newWatchService()

Implements abstract java.nio.file.FileSystem.newWatchService.

Doc from java.nio.file.FileSystem.newWatchService.

Constructs a new WatchService (optional operation).

This method constructs a new watch service that may be used to watch registered objects for changes and events.

Annotations
@Override
providerback to summary
public FileSystemProvider provider()

Implements abstract java.nio.file.FileSystem.provider.

Doc from java.nio.file.FileSystem.provider.

Returns the provider that created this file system.

Annotations
@Override
readOnlyback to summary
pack-priv static ReadOnlyFileSystemException readOnly()
setTimesback to summary
pack-priv final void setTimes(JrtPath jrtPath, FileTime mtime, FileTime atime, FileTime ctime) throws IOException
supportedFileAttributeViewsback to summary
public final Set<String> supportedFileAttributeViews()

Implements abstract java.nio.file.FileSystem.supportedFileAttributeViews.

Doc from java.nio.file.FileSystem.supportedFileAttributeViews.

Returns the set of the names of the file attribute views supported by this FileSystem.

The BasicFileAttributeView is required to be supported and therefore the set contains at least one element, "basic".

The supportsFileAttributeView(String) method may be used to test if an underlying FileStore supports the file attributes identified by a file attribute view.

Annotations
@Override
toRealPathback to summary
pack-priv JrtPath toRealPath(JrtPath path, LinkOption... options) throws IOException
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override