langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
equal
deleted
inserted
replaced
67 import javax.tools.JavaFileObject; |
67 import javax.tools.JavaFileObject; |
68 import javax.tools.StandardJavaFileManager; |
68 import javax.tools.StandardJavaFileManager; |
69 |
69 |
70 import com.sun.tools.javac.file.RelativePath.RelativeDirectory; |
70 import com.sun.tools.javac.file.RelativePath.RelativeDirectory; |
71 import com.sun.tools.javac.file.RelativePath.RelativeFile; |
71 import com.sun.tools.javac.file.RelativePath.RelativeFile; |
|
72 import com.sun.tools.javac.util.Assert; |
72 import com.sun.tools.javac.util.Context; |
73 import com.sun.tools.javac.util.Context; |
73 import com.sun.tools.javac.util.DefinedBy; |
74 import com.sun.tools.javac.util.DefinedBy; |
74 import com.sun.tools.javac.util.DefinedBy.Api; |
75 import com.sun.tools.javac.util.DefinedBy.Api; |
75 import com.sun.tools.javac.util.List; |
76 import com.sun.tools.javac.util.List; |
76 import com.sun.tools.javac.util.ListBuffer; |
77 import com.sun.tools.javac.util.ListBuffer; |
507 |
508 |
508 public ArchiveContainer(Path archivePath) throws IOException, ProviderNotFoundException, SecurityException { |
509 public ArchiveContainer(Path archivePath) throws IOException, ProviderNotFoundException, SecurityException { |
509 this.archivePath = archivePath; |
510 this.archivePath = archivePath; |
510 if (multiReleaseValue != null && archivePath.toString().endsWith(".jar")) { |
511 if (multiReleaseValue != null && archivePath.toString().endsWith(".jar")) { |
511 Map<String,String> env = Collections.singletonMap("multi-release", multiReleaseValue); |
512 Map<String,String> env = Collections.singletonMap("multi-release", multiReleaseValue); |
512 this.fileSystem = getJarFSProvider().newFileSystem(archivePath, env); |
513 FileSystemProvider jarFSProvider = fsInfo.getJarFSProvider(); |
|
514 Assert.checkNonNull(jarFSProvider, "should have been caught before!"); |
|
515 this.fileSystem = jarFSProvider.newFileSystem(archivePath, env); |
513 } else { |
516 } else { |
514 this.fileSystem = FileSystems.newFileSystem(archivePath, null); |
517 this.fileSystem = FileSystems.newFileSystem(archivePath, null); |
515 } |
518 } |
516 } |
519 } |
517 |
520 |
593 |
596 |
594 @Override |
597 @Override |
595 public void close() throws IOException { |
598 public void close() throws IOException { |
596 fileSystem.close(); |
599 fileSystem.close(); |
597 } |
600 } |
598 } |
|
599 |
|
600 private FileSystemProvider jarFSProvider; |
|
601 |
|
602 private FileSystemProvider getJarFSProvider() throws IOException { |
|
603 if (jarFSProvider != null) { |
|
604 return jarFSProvider; |
|
605 } |
|
606 for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { |
|
607 if (provider.getScheme().equals("jar")) { |
|
608 return (jarFSProvider = provider); |
|
609 } |
|
610 } |
|
611 throw new ProviderNotFoundException("no provider found for .jar files"); |
|
612 } |
601 } |
613 |
602 |
614 /** |
603 /** |
615 * container is a directory, a zip file, or a non-existent path. |
604 * container is a directory, a zip file, or a non-existent path. |
616 */ |
605 */ |