Skip to content

Commit

Permalink
Set dex jars as read-only.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Jul 21, 2023
1 parent 666fc4e commit ed12ecf
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,16 @@ public Map<TypeDescription, Class<?>> load(@MaybeNull ClassLoader classLoader, M
if (!jar.createNewFile()) {
throw new IllegalStateException("Cannot create " + jar);
}
JarOutputStream zipOutputStream = new JarOutputStream(new FileOutputStream(jar));
JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(jar));
try {
zipOutputStream.putNextEntry(new JarEntry(DEX_CLASS_FILE));
conversion.drainTo(zipOutputStream);
zipOutputStream.closeEntry();
outputStream.putNextEntry(new JarEntry(DEX_CLASS_FILE));
conversion.drainTo(outputStream);
outputStream.closeEntry();
} finally {
zipOutputStream.close();
outputStream.close();
}
if (!jar.setReadOnly()) {
throw new IllegalStateException("Failed to set jar read-only " + jar.getAbsolutePath());
}
return doLoad(classLoader, types.keySet(), jar);
} catch (IOException exception) {
Expand Down

0 comments on commit ed12ecf

Please sign in to comment.