< prev index next >

src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java

Print this page
rev 55068 : 8224908: Revert: 8216553: JrtFileSystemProvider getPath(URI) omits /modules element from file path
Reviewed-by:


 173                 }
 174         );
 175     }
 176 
 177     @Override
 178     public Path getPath(URI uri) {
 179         checkPermission();
 180         if (!uri.getScheme().equalsIgnoreCase(getScheme())) {
 181             throw new IllegalArgumentException("URI does not match this provider");
 182         }
 183         if (uri.getAuthority() != null) {
 184             throw new IllegalArgumentException("Authority component present");
 185         }
 186         if (uri.getQuery() != null) {
 187             throw new IllegalArgumentException("Query component present");
 188         }
 189         if (uri.getFragment() != null) {
 190             throw new IllegalArgumentException("Fragment component present");
 191         }
 192         String path = uri.getPath();
 193         if (path == null || path.charAt(0) != '/' || path.contains("..")) {
 194             throw new IllegalArgumentException("Invalid path component");
 195         }
 196         return getTheFileSystem().getPath("/modules" + path);
 197     }
 198 
 199     private FileSystem getTheFileSystem() {
 200         checkPermission();
 201         FileSystem fs = this.theFileSystem;
 202         if (fs == null) {
 203             synchronized (this) {
 204                 fs = this.theFileSystem;
 205                 if (fs == null) {
 206                     try {
 207                         this.theFileSystem = fs = new JrtFileSystem(this, null);
 208                     } catch (IOException ioe) {
 209                         throw new InternalError(ioe);
 210                     }
 211                 }
 212             }
 213         }
 214         return fs;
 215     }
 216 




 173                 }
 174         );
 175     }
 176 
 177     @Override
 178     public Path getPath(URI uri) {
 179         checkPermission();
 180         if (!uri.getScheme().equalsIgnoreCase(getScheme())) {
 181             throw new IllegalArgumentException("URI does not match this provider");
 182         }
 183         if (uri.getAuthority() != null) {
 184             throw new IllegalArgumentException("Authority component present");
 185         }
 186         if (uri.getQuery() != null) {
 187             throw new IllegalArgumentException("Query component present");
 188         }
 189         if (uri.getFragment() != null) {
 190             throw new IllegalArgumentException("Fragment component present");
 191         }
 192         String path = uri.getPath();
 193         if (path == null || path.charAt(0) != '/') {
 194             throw new IllegalArgumentException("Invalid path component");
 195         }
 196         return getTheFileSystem().getPath(path);
 197     }
 198 
 199     private FileSystem getTheFileSystem() {
 200         checkPermission();
 201         FileSystem fs = this.theFileSystem;
 202         if (fs == null) {
 203             synchronized (this) {
 204                 fs = this.theFileSystem;
 205                 if (fs == null) {
 206                     try {
 207                         this.theFileSystem = fs = new JrtFileSystem(this, null);
 208                     } catch (IOException ioe) {
 209                         throw new InternalError(ioe);
 210                     }
 211                 }
 212             }
 213         }
 214         return fs;
 215     }
 216 


< prev index next >