use of org.mapleir.Main in project maple-ir by LLVM-but-worse.
the class RunCommand method dumpJar.
private void dumpJar(ApplicationClassSource app, SingleJarDownloader<ClassNode> dl, PassGroup masterGroup, String outputFile) throws IOException {
(new CompleteResolvingJarDumper(dl.getJarContents(), app) {
@Override
public int dumpResource(JarOutputStream out, String name, byte[] file) throws IOException {
// }
if (name.equals("META-INF/MANIFEST.MF")) {
ClassRenamerPass renamer = (ClassRenamerPass) masterGroup.getPass(e -> e.is(ClassRenamerPass.class));
if (renamer != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(baos));
BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(file)));
String line;
while ((line = br.readLine()) != null) {
String[] parts = line.split(": ", 2);
if (parts.length != 2) {
bw.write(line);
continue;
}
if (parts[0].equals("Main-Class")) {
String newMain = renamer.getRemappedName(parts[1].replace(".", "/")).replace("/", ".");
logger.print(String.format("%s -> %s%n", parts[1], newMain));
parts[1] = newMain;
}
bw.write(parts[0]);
bw.write(": ");
bw.write(parts[1]);
bw.write(System.lineSeparator());
}
br.close();
bw.close();
file = baos.toByteArray();
}
}
return super.dumpResource(out, name, file);
}
}).dump(new File(outputFile));
}
Aggregations