use of org.mapleir.app.service.CompleteResolvingJarDumper in project maple-ir by LLVM-but-worse.
the class Boot method dumpJar.
private static 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.info(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