1212import java .util .List ;
1313import java .util .Map ;
1414import java .util .Set ;
15+ import java .util .jar .JarEntry ;
1516import java .util .logging .Level ;
1617import java .util .stream .Collectors ;
1718import java .util .zip .ZipEntry ;
@@ -83,13 +84,15 @@ private void processJar(Path inFile, Path outFile) throws IOException
8384 Set <String > entries = new HashSet <>();
8485 try (ZipInputStream inJar = new ZipInputStream (Files .newInputStream (inFile )))
8586 {
86- try (ZipOutputStream outJar = new ZipOutputStream (outFile == null ? new ByteArrayOutputStream () : Files .newOutputStream (outFile , StandardOpenOption . CREATE )))
87+ try (ZipOutputStream outJar = new ZipOutputStream (outFile == null ? new ByteArrayOutputStream () : Files .newOutputStream (outFile )))
8788 {
8889 for (ZipEntry entry = inJar .getNextEntry (); entry != null ; entry = inJar .getNextEntry ())
8990 {
91+ String entryName = entry .getName ();
92+
9093 if (entry .isDirectory ())
9194 {
92- outJar .putNextEntry (entry );
95+ outJar .putNextEntry (new JarEntry ( entryName ) );
9396 outJar .closeEntry ();
9497 continue ;
9598 }
@@ -109,8 +112,6 @@ private void processJar(Path inFile, Path outFile) throws IOException
109112
110113 byte [] entryData = entryBuffer .toByteArray ();
111114
112- String entryName = entry .getName ();
113-
114115 boolean mojang = entryName .startsWith ("net/minecraft/" ) || entryName .startsWith ("com/mojang/" );
115116
116117 if (entryName .endsWith (".class" ) && mojang ) //TODO: Remove this hardcoding? SRG input? process all?
@@ -136,9 +137,9 @@ private void processJar(Path inFile, Path outFile) throws IOException
136137
137138 if (!abstractParameters .isEmpty () && !entries .contains ("fernflower_abstract_parameter_names.txt" ))
138139 {
139- ZipEntry entry = new ZipEntry ("fernflower_abstract_parameter_names.txt" );
140- entry .setTime (0 ); //Stabilize time.
141- outJar .putNextEntry (entry );
140+ ZipEntry newEntry = new ZipEntry ("fernflower_abstract_parameter_names.txt" );
141+ newEntry .setTime (0 ); //Stabilize time.
142+ outJar .putNextEntry (newEntry );
142143 for (String key : abstractParameters .keySet ().stream ().sorted ().collect (Collectors .toList ()))
143144 {
144145 outJar .write (key .getBytes (StandardCharsets .UTF_8 ));//class method desc
@@ -148,8 +149,6 @@ private void processJar(Path inFile, Path outFile) throws IOException
148149 }
149150 outJar .closeEntry ();
150151 }
151-
152- outJar .flush ();
153152 }
154153 }
155154 }
0 commit comments