From 4d87b447a68614dc874e4949f9e55dc485fc7b19 Mon Sep 17 00:00:00 2001 From: Skylot Date: Fri, 22 Sep 2023 20:31:56 +0100 Subject: [PATCH] chore: remove unused code in ClsSet class (#2020) --- .../java/jadx/cli/clst/ConvertToClsSet.java | 2 +- .../src/main/java/jadx/core/clsp/ClsSet.java | 55 ------------------- 2 files changed, 1 insertion(+), 56 deletions(-) diff --git a/jadx-cli/src/main/java/jadx/cli/clst/ConvertToClsSet.java b/jadx-cli/src/main/java/jadx/cli/clst/ConvertToClsSet.java index d23cd87fb..2ecd2f4d6 100644 --- a/jadx-cli/src/main/java/jadx/cli/clst/ConvertToClsSet.java +++ b/jadx-cli/src/main/java/jadx/cli/clst/ConvertToClsSet.java @@ -23,7 +23,7 @@ public class ConvertToClsSet { private static final Logger LOG = LoggerFactory.getLogger(ConvertToClsSet.class); public static void usage() { - LOG.info(" "); + LOG.info(" "); LOG.info("Arguments to update core.jcst: " + "/jadx-core/src/main/resources/clst/core.jcst " + "/platforms/android-/android.jar" diff --git a/jadx-core/src/main/java/jadx/core/clsp/ClsSet.java b/jadx-core/src/main/java/jadx/core/clsp/ClsSet.java index 7c2bb4b4b..4010acd26 100644 --- a/jadx-core/src/main/java/jadx/core/clsp/ClsSet.java +++ b/jadx-core/src/main/java/jadx/core/clsp/ClsSet.java @@ -4,14 +4,11 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -19,15 +16,11 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Stream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import jadx.api.plugins.utils.ZipSecurity; import jadx.core.dex.info.AccessInfo; import jadx.core.dex.info.ClassInfo; import jadx.core.dex.info.MethodInfo; @@ -191,33 +184,6 @@ public class ClsSet { try (BufferedOutputStream outputStream = new BufferedOutputStream(Files.newOutputStream(path))) { save(outputStream); } - } else if (outputName.endsWith(".jar")) { - Path temp = FileUtils.createTempFile(".zip"); - Files.copy(path, temp, StandardCopyOption.REPLACE_EXISTING); - - try (ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(path)); - ZipInputStream in = new ZipInputStream(Files.newInputStream(temp))) { - String clst = CLST_PATH; - boolean clstReplaced = false; - ZipEntry entry = in.getNextEntry(); - while (entry != null) { - String entryName = entry.getName(); - ZipEntry copyEntry = new ZipEntry(entryName); - copyEntry.setLastModifiedTime(entry.getLastModifiedTime()); // preserve modified time - out.putNextEntry(copyEntry); - if (entryName.equals(clst)) { - save(out); - clstReplaced = true; - } else { - FileUtils.copyStream(in, out); - } - entry = in.getNextEntry(); - } - if (!clstReplaced) { - out.putNextEntry(new ZipEntry(clst)); - save(out); - } - } } else { throw new JadxRuntimeException("Unknown file format: " + outputName); } @@ -324,27 +290,6 @@ public class ClsSet { } } - private void load(File input) throws IOException, DecodeException { - String name = input.getName(); - if (name.endsWith(CLST_EXTENSION)) { - try (InputStream inputStream = new FileInputStream(input)) { - load(inputStream); - } - } else if (name.endsWith(".jar")) { - ZipSecurity.readZipEntries(input, (entry, in) -> { - if (entry.getName().endsWith(CLST_EXTENSION)) { - try { - load(in); - } catch (Exception e) { - throw new JadxRuntimeException("Failed to load jadx class set"); - } - } - }); - } else { - throw new JadxRuntimeException("Unknown file format: " + name); - } - } - private void load(InputStream input) throws IOException, DecodeException { try (DataInputStream in = new DataInputStream(new BufferedInputStream(input))) { byte[] header = new byte[JADX_CLS_SET_HEADER.length()];