-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Read only ZIP file system. #24506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Read only ZIP file system. #24506
Changes from all commits
8c2bf36
dec46fb
4302846
ce10ed5
e8aff8f
0d99b32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -561,17 +561,17 @@ private final class ArchiveContainer implements Container { | |
|
||
public ArchiveContainer(Path archivePath) throws IOException, ProviderNotFoundException { | ||
this.archivePath = archivePath; | ||
|
||
if (multiReleaseValue != null && archivePath.toString().endsWith(".jar")) { | ||
Map<String,String> env = Collections.singletonMap("multi-release", multiReleaseValue); | ||
FileSystemProvider jarFSProvider = fsInfo.getJarFSProvider(); | ||
Assert.checkNonNull(jarFSProvider, "should have been caught before!"); | ||
try { | ||
this.fileSystem = jarFSProvider.newFileSystem(archivePath, env); | ||
this.fileSystem = jarFSProvider.newFileSystem(archivePath, FSInfo.getReadOnlyJarEnv(multiReleaseValue)); | ||
} catch (ZipException ze) { | ||
throw new IOException("ZipException opening \"" + archivePath.getFileName() + "\": " + ze.getMessage(), ze); | ||
} | ||
} else { | ||
this.fileSystem = FileSystems.newFileSystem(archivePath, (ClassLoader)null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Existing code is passing null, but that constructor path is identical to the ones not passing a classloader at all. |
||
this.fileSystem = FileSystems.newFileSystem(archivePath, FSInfo.getReadOnlyZipEnv()); | ||
} | ||
packages = new HashMap<>(); | ||
for (Path root : fileSystem.getRootDirectories()) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1756,12 +1756,16 @@ public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue, Queue<Jav | |
if (results != null && file != null) | ||
results.add(file); | ||
} catch (IOException | ||
| UncheckedIOException | ||
| FileSystemNotFoundException | ||
| InvalidPathException | ||
| ReadOnlyFileSystemException ex) { | ||
| UncheckedIOException | ||
| FileSystemNotFoundException | ||
| InvalidPathException | ||
| ReadOnlyFileSystemException ex) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is just about adding slightly more useful information to the (common) case when no exception message exists. It helped me when debugging. |
||
String msg = ex.getMessage(); | ||
if (msg == null || msg.isEmpty()) { | ||
msg = ex.getClass().getSimpleName(); | ||
} | ||
log.error(cdef.pos(), | ||
Errors.ClassCantWrite(cdef.sym, ex.getMessage())); | ||
Errors.ClassCantWrite(cdef.sym, msg)); | ||
return; | ||
} finally { | ||
log.useSource(prev); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a helper here (it seemed like the right place). Happy to move or inline stuff.