< prev index next > src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java
Print this page
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.internal.jrtfs;
+ import jdk.internal.jimage.PreviewMode;
+
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.channels.*;
import java.util.Set;
import java.util.concurrent.ExecutorService;
/**
* File system provider for jrt file systems. Conditionally creates jrt fs on
- * .jimage file or exploded modules directory of underlying JDK.
+ * a jimage file, or exploded modules directory of underlying JDK.
*
* @implNote 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
checkPermission();
checkUri(uri);
if (env.containsKey("java.home")) {
return newFileSystem((String)env.get("java.home"), uri, env);
} else {
- return new JrtFileSystem(this, env);
+ return new JrtFileSystem(this, parsePreviewMode(env.get("previewMode")));
+ }
+ }
+
+ // Currently this does not support specifying "for runtime", because it is
+ // expected that callers creating non-standard image readers will not be
+ // using them to read resources for the current runtime (they would just
+ // use "jrt:" URLs if they were doing that).
+ private static PreviewMode parsePreviewMode(Object envValue) {
+ if (envValue instanceof String && Boolean.parseBoolean((String) envValue)) {
+ return PreviewMode.ENABLED;
}
+ // Default (unspecified/null or bad parameter) is to not use preview mode.
+ return PreviewMode.DISABLED;
}
private static final String JRT_FS_JAR = "jrt-fs.jar";
private FileSystem newFileSystem(String targetHome, URI uri, Map<String, ?> env)
throws IOException {
if (fs == null) {
synchronized (this) {
fs = this.theFileSystem;
if (fs == null) {
try {
- this.theFileSystem = fs = new JrtFileSystem(this, null);
+ // Special constructor call for singleton instance.
+ this.theFileSystem = fs = new JrtFileSystem(this);
} catch (IOException ioe) {
throw new InternalError(ioe);
}
}
}
checkUri(uri);
return getTheFileSystem();
}
// Checks that the given file is a JrtPath
- static final JrtPath toJrtPath(Path path) {
+ static JrtPath toJrtPath(Path path) {
Objects.requireNonNull(path, "path");
if (!(path instanceof JrtPath)) {
throw new ProviderMismatchException();
}
return (JrtPath) path;
throws IOException {
toJrtPath(path).createDirectory(attrs);
}
@Override
- public final void delete(Path path) throws IOException {
+ public void delete(Path path) throws IOException {
toJrtPath(path).delete();
}
@Override
public <V extends FileAttributeView> V
< prev index next >