Fix .class files are exported in a wrong way
@@ -16,6 +16,8 @@ import org.objectweb.asm.tree.InnerClassNode;
import java.io.*;
import java.lang.instrument.*;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
import java.security.ProtectionDomain;
import java.util.*;
import java.util.Map.Entry;
@@ -416,6 +418,14 @@ public class Input{
// output.
Bus.post(new ExportEvent(event.getFile(), contents));
// Save contents to jar.
+
+ if (event.getFile().getName().endsWith(".class")) {
+ if (contents.size() != 1) {
+ Logging.error("Cannot export multiple resources into .class file!");
+ return;
+ }
+ Files.write(event.getFile().toPath(), contents.values().iterator().next(), StandardOpenOption.CREATE);
+ } else {
try (JarOutputStream output = new JarOutputStream(new FileOutputStream(event.getFile()))) {
Set<String> dirsVisited = new HashSet<>();
// Contents is iterated in sorted order (because type is TreeMap).
@@ -447,6 +457,7 @@ public class Input{
output.closeEntry();
}
}
+ }
Logging.info("Exported to: " + event.getFile());
}
