Even more applications of the Law of Demeter

This commit is contained in:
Nico Mexis 2021-08-27 10:49:31 +02:00
parent 0d7b7c5de8
commit b18bc950e1
No known key found for this signature in database
GPG key ID: 27D6E17CE092AB78
36 changed files with 94 additions and 78 deletions

View file

@ -5,6 +5,7 @@ import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import the.bytecode.club.bytecodeviewer.util.EncodeUtils;
@ -18,14 +19,14 @@ import the.bytecode.club.bytecodeviewer.util.EncodeUtils;
public class DiskReader {
public static Random random = new Random();
public static Map<String, ArrayList<String>> map = new HashMap<>();
public static Map<String, List<String>> map = new HashMap<>();
/**
* Used to load from file, allows caching
*/
public synchronized static ArrayList<String> loadArrayList(String fileName,
public synchronized static List<String> loadArrayList(String fileName,
boolean cache) {
ArrayList<String> array = new ArrayList<>();
List<String> array = new ArrayList<>();
if (!map.containsKey(fileName)) {
try {
File file = new File(fileName);
@ -76,7 +77,7 @@ public class DiskReader {
public static String loadString(String fileName, int lineNumber,
boolean cache) throws Exception {
ArrayList<String> array;
List<String> array;
if (!map.containsKey(fileName)) {
array = new ArrayList<>();
File file = new File(fileName);

View file

@ -142,7 +142,7 @@ public class HTTPRequest {
* @throws Exception
*/
public String[] read() throws Exception {
ArrayList<String> st;
List<String> st;
try {
setup();
@ -172,7 +172,7 @@ public class HTTPRequest {
* @throws Exception
*/
public String[] read(int linesToRead) throws Exception {
ArrayList<String> st;
List<String> st;
try {
setup();

View file

@ -432,9 +432,9 @@ public class BytecodeViewer
* @return the loaded classes as an array list
*/
@Deprecated
public static ArrayList<ClassNode> getLoadedClasses()
public static List<ClassNode> getLoadedClasses()
{
ArrayList<ClassNode> a = new ArrayList<>();
List<ClassNode> a = new ArrayList<>();
for (ResourceContainer container : resourceContainers.values())
for (ClassNode c : container.resourceClasses.values())

View file

@ -189,7 +189,7 @@ public class BCV
*
* @return the loaded classes
*/
public static ArrayList<ClassNode> getLoadedClasses() {
public static List<ClassNode> getLoadedClasses() {
return the.bytecode.club.bytecodeviewer.BytecodeViewer
.getLoadedClasses();
}

View file

@ -8,6 +8,7 @@ import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
@ -73,7 +74,7 @@ public final class ClassNodeLoader extends ClassLoader
* @return All classes in this loader
*/
public Collection<Class<?>> getAllClasses() {
ArrayList<Class<?>> classes = new ArrayList<>();
List<Class<?>> classes = new ArrayList<>();
for (String s : this.classes.keySet()) {
try {
classes.add(loadClass(s));

View file

@ -1,6 +1,7 @@
package the.bytecode.club.bytecodeviewer.api;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
@ -94,5 +95,5 @@ public abstract class Plugin extends Thread
*
* @param classNodeList all of the loaded classes for easy access.
*/
public abstract void execute(ArrayList<ClassNode> classNodeList);
public abstract void execute(List<ClassNode> classNodeList);
}

View file

@ -38,9 +38,9 @@ import static the.bytecode.club.bytecodeviewer.Constants.nl;
public class ClassNodeDecompiler
{
public static PrefixedStringBuilder decompile(
PrefixedStringBuilder sb, ArrayList<String> decompiledClasses,
PrefixedStringBuilder sb, List<String> decompiledClasses,
ClassNode cn) {
ArrayList<String> unableToDecompile = new ArrayList<>();
List<String> unableToDecompile = new ArrayList<>();
decompiledClasses.add(cn.name);
sb.append(getAccessString(cn.access));
sb.append(" ");

View file

@ -69,7 +69,7 @@ public class InstructionPrinter {
protected List<AbstractInsnNode> matchedInsns;
protected Map<LabelNode, Integer> labels;
private boolean firstLabel = false;
private final ArrayList<String> info = new ArrayList<>();
private final List<String> info = new ArrayList<>();
public InstructionPrinter(MethodNode m, TypeAndName[] args) {
this.args = args;
@ -99,7 +99,7 @@ public class InstructionPrinter {
*
* @return The print as an ArrayList
*/
public ArrayList<String> createPrint() {
public List<String> createPrint() {
firstLabel = false;
info.clear();
for (AbstractInsnNode ain : mNode.instructions) {

View file

@ -110,7 +110,7 @@ public class MainViewerGUI extends JFrame
public final List<JMenuItem> waitIcons = new ArrayList<>();
//main UI components
public final ArrayList<VisibleComponent> uiComponents = new ArrayList<>();
public final List<VisibleComponent> uiComponents = new ArrayList<>();
public final Workspace workPane = new Workspace();
public final ResourceListPane resourcePane = new ResourceListPane();
public final SearchBoxPane searchBoxPane = new SearchBoxPane();
@ -915,7 +915,7 @@ public class MainViewerGUI extends JFrame
if (dialog.promptChoice() == 0)
{
LazyNameUtil.reset();
ArrayList<File> reopen = new ArrayList<>();
List<File> reopen = new ArrayList<>();
for (ResourceContainer container : BytecodeViewer.resourceContainers.values())
{

View file

@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.gui.components;
import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -40,7 +41,7 @@ public class FileChooser extends JFileChooser
public FileChooser(boolean skipFileFilter, File file, String title, String description, String... extensions)
{
HashSet<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
Set<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
try {
if(file.isDirectory())

View file

@ -1,6 +1,7 @@
package the.bytecode.club.bytecodeviewer.gui.contextmenu;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JPopupMenu;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
@ -39,7 +40,7 @@ import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
public class ContextMenu
{
private static ContextMenu SINGLETON = new ContextMenu();
private final ArrayList<ContextMenuItem> contextMenuItems = new ArrayList<>();
private final List<ContextMenuItem> contextMenuItems = new ArrayList<>();
static
{

View file

@ -2,6 +2,7 @@ package the.bytecode.club.bytecodeviewer.gui.plugins;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
@ -55,7 +56,7 @@ public class MaliciousCodeScannerOptions extends JFrame
setResizable(false);
setTitle("Malicious Code Scanner Options");
getContentPane().setLayout(null);
ArrayList<MaliciousCodeOptions> checkBoxes = new ArrayList<>();
List<MaliciousCodeOptions> checkBoxes = new ArrayList<>();
int y = 7;
for(MalwareScanModule module : MalwareScanModule.values())

View file

@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.gui.resourcelist;
import java.awt.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JTree;
@ -77,8 +78,8 @@ public class ResourceListIconRenderer extends DefaultTreeCellRenderer
//folders
if (node.getChildCount() > 0)
{
ArrayList<TreeNode> nodes = new ArrayList<>();
ArrayList<TreeNode> totalNodes = new ArrayList<>();
List<TreeNode> nodes = new ArrayList<>();
List<TreeNode> totalNodes = new ArrayList<>();
nodes.add(node);
totalNodes.add(node);

View file

@ -7,6 +7,7 @@ import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.HashSet;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
@ -56,7 +57,7 @@ public class Workspace extends TranslatedVisibleComponent
public final JTabbedPane tabs;
public final JPanel buttonPanel;
public final JButton refreshClass;
public final HashSet<String> openedTabs = new HashSet<>();
public final Set<String> openedTabs = new HashSet<>();
public Workspace()
{

View file

@ -1,7 +1,7 @@
package the.bytecode.club.bytecodeviewer.malwarescanner;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.objectweb.asm.tree.ClassNode;
/***************************************************************************
@ -33,11 +33,11 @@ import org.objectweb.asm.tree.ClassNode;
*/
public class MalwareScan
{
public final ArrayList<ClassNode> classNodeList;
public final List<ClassNode> classNodeList;
public final StringBuilder sb;
public final HashSet<String> scanOptions;
public final Set<String> scanOptions;
public MalwareScan(ArrayList<ClassNode> classNodeList, StringBuilder sb, HashSet<String> scanOptions)
public MalwareScan(List<ClassNode> classNodeList, StringBuilder sb, Set<String> scanOptions)
{
this.classNodeList = classNodeList;
this.sb = sb;

View file

@ -1,6 +1,7 @@
package the.bytecode.club.bytecodeviewer.obfuscators;
import java.util.ArrayList;
import java.util.List;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -52,7 +53,7 @@ public abstract class JavaObfuscator extends Thread {
public static int MAX_STRING_LENGTH = 25;
public static int MIN_STRING_LENGTH = 5;
private final ArrayList<String> names = new ArrayList<>();
private final List<String> names = new ArrayList<>();
protected String generateUniqueName(int length) {
boolean found = false;

View file

@ -3,7 +3,7 @@ package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.awt.Dimension;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
@ -61,7 +61,7 @@ public class AllatoriStringDecrypter extends Plugin
public AllatoriStringDecrypter(String className) {this.className = className;}
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
PluginConsole frame = new PluginConsole("Allatori String Decrypter");
@ -284,7 +284,7 @@ public class AllatoriStringDecrypter extends Plugin
public static class AllatoriStringDecrypterOptions extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
new AllatoriStringDecrypterOptionsFrame().setVisible(true);
}

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.Plugin;
@ -18,7 +18,7 @@ import the.bytecode.club.bytecodeviewer.api.Plugin;
public class ChangeClassFileVersions extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
//prompt dialog for version number
// TODO: include a little diagram of what JDK is which number

View file

@ -5,7 +5,7 @@ import com.mxgraph.view.mxGraph;
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.UIManager;
import org.objectweb.asm.tree.AbstractInsnNode;
@ -50,7 +50,7 @@ public class CodeSequenceDiagram extends Plugin
}
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
if (!BytecodeViewer.isActiveResourceClass())
{

View file

@ -4,6 +4,7 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
@ -49,7 +50,7 @@ import static the.bytecode.club.bytecodeviewer.Constants.nl;
public class EZInjection extends Plugin
{
public static ArrayList<BytecodeHook> hookArray = new ArrayList<>();
public static List<BytecodeHook> hookArray = new ArrayList<>();
private static final String version = "1.0";
private final boolean accessModifiers;
private final boolean injectHooks;
@ -137,7 +138,7 @@ public class EZInjection extends Plugin
}
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
if(console)
new PluginConsole("EZ Injection v" + version);

View file

@ -1,8 +1,8 @@
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.api.Plugin;
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
@ -48,12 +48,12 @@ public class MaliciousCodeScanner extends Plugin
}
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
PluginConsole frame = new PluginConsole("Malicious Code Scanner");
StringBuilder sb = new StringBuilder();
HashSet<String> scanOptions = new HashSet<>();
Set<String> scanOptions = new HashSet<>();
for(MaliciousCodeOptions option : options)
if(option.getCheckBox().isSelected())

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
@ -51,7 +51,7 @@ public class ReplaceStrings extends Plugin
}
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
frame = new PluginConsole("Replace Strings");

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
@ -39,7 +39,7 @@ import static the.bytecode.club.bytecodeviewer.Constants.nl;
public class ShowAllStrings extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
PluginConsole frame = new PluginConsole("Show All Strings");
StringBuilder sb = new StringBuilder();

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
@ -37,7 +37,7 @@ public class ShowMainMethods extends Plugin
private static final int PUBLIC_STATIC = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC;
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
PluginConsole frame = new PluginConsole("Show Main Methods");
StringBuilder sb = new StringBuilder();

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
@ -12,7 +12,7 @@ import the.bytecode.club.bytecodeviewer.api.PluginConsole;
public class StackFramesRemover extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
AtomicInteger counter = new AtomicInteger();
PluginConsole frame = new PluginConsole("StackFrames Remover");

View file

@ -1,7 +1,7 @@
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.api.Plugin;
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
@ -13,7 +13,7 @@ import the.bytecode.club.bytecodeviewer.api.PluginConsole;
public class ViewAPKAndroidPermissions extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
PluginConsole frame = new PluginConsole("Android Permissions");
frame.setVisible(true);

View file

@ -1,7 +1,7 @@
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.api.Plugin;
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
@ -13,7 +13,7 @@ import the.bytecode.club.bytecodeviewer.api.PluginConsole;
public class ViewManifest extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
PluginConsole frame = new PluginConsole("View Manifest");
frame.setVisible(true);

View file

@ -1,6 +1,6 @@
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.Plugin;
@ -32,7 +32,7 @@ import the.bytecode.club.bytecodeviewer.api.Plugin;
public class ZKMStringDecrypter extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
BytecodeViewer.showMessage("This is a planned feature.");
}

View file

@ -2,7 +2,7 @@ package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -41,7 +41,7 @@ import static the.bytecode.club.bytecodeviewer.Constants.nl;
public class ZStringArrayDecrypter extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
PluginConsole gui = new PluginConsole("ZStringArray Decrypter");
StringBuilder out = new StringBuilder();

View file

@ -3,7 +3,7 @@ package the.bytecode.club.bytecodeviewer.plugin.strategies;
import java.io.File;
import java.io.FileReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import javax.script.Bindings;
import javax.script.Invocable;
import javax.script.ScriptContext;
@ -73,7 +73,7 @@ public class JavascriptPluginLaunchStrategy implements PluginLaunchStrategy
return new Plugin()
{
@Override
public void execute(ArrayList<ClassNode> classNodeList)
public void execute(List<ClassNode> classNodeList)
{
try
{

View file

@ -5,6 +5,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FilenameUtils;
import org.objectweb.asm.tree.ClassNode;
@ -47,7 +48,7 @@ public class DirectoryResourceImporter implements Importer
Map<String, ClassNode> allDirectoryClasses = new LinkedHashMap<>();
boolean finished = false;
ArrayList<File> totalFiles = new ArrayList<>();
List<File> totalFiles = new ArrayList<>();
totalFiles.add(file);
String dir = file.getAbsolutePath();

View file

@ -8,6 +8,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections4.map.LinkedMap;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Constants;
@ -96,7 +97,7 @@ public enum Language
private final String resourcePath;
private final String readableName;
private final String htmlIdentifier;
private final LinkedHashSet<String> languageCode;
private final Set<String> languageCode;
private Map<String, String> translationMap;
Language(String resourcePath, String readableName, String htmlIdentifier, String... languageCodes)
@ -175,7 +176,7 @@ public enum Language
IconResources.loadResourceAsString(resourcePath),
new TypeToken<LinkedMap<String, String>>(){}.getType());
HashSet<String> existingKeys = new HashSet<>();
Set<String> existingKeys = new HashSet<>();
for(TranslatedComponents t : TranslatedComponents.values())
existingKeys.add(t.name());
@ -189,7 +190,7 @@ public enum Language
return resourcePath;
}
public HashSet<String> getLanguageCode()
public Set<String> getLanguageCode()
{
return languageCode;
}

View file

@ -2,6 +2,7 @@ package the.bytecode.club.bytecodeviewer.translation;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import the.bytecode.club.bytecodeviewer.api.BCV;
/***************************************************************************
@ -121,7 +122,7 @@ public enum TranslatedStrings
DRAG_CLASS_JAR,
;
public static final HashSet<String> nameSet = new HashSet<>();
public static final Set<String> nameSet = new HashSet<>();
static
{

View file

@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.util;
import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -89,7 +90,7 @@ public class DialogUtils
*/
public static File fileChooser(String title, String description, File directory, FileFilter filter, OnOpenEvent onOpen, String... extensions)
{
HashSet<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
Set<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
final JFileChooser fc = new FileChooser(true,
directory,

View file

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.jar.JarOutputStream;
@ -159,9 +160,9 @@ public class JarUtils
BytecodeViewer.addResourceContainer(container);
}
public static ArrayList<ClassNode> loadClasses(final File jarFile) throws IOException
public static List<ClassNode> loadClasses(final File jarFile) throws IOException
{
ArrayList<ClassNode> classes = new ArrayList<>();
List<ClassNode> classes = new ArrayList<>();
try (FileInputStream fis = new FileInputStream(jarFile);
ZipInputStream jis = new ZipInputStream(fis)) {
ZipEntry entry;
@ -249,7 +250,7 @@ public class JarUtils
* @param path the exact path of the output jar file
* @param manifest the manifest contents
*/
public static void saveAsJar(ArrayList<ClassNode> nodeList, String path,
public static void saveAsJar(List<ClassNode> nodeList, String path,
String manifest) {
try (FileOutputStream fos = new FileOutputStream(path);
JarOutputStream out = new JarOutputStream(fos)) {
@ -295,7 +296,7 @@ public class JarUtils
try (FileOutputStream fos = new FileOutputStream(path);
JarOutputStream out = new JarOutputStream(fos))
{
ArrayList<String> noDupe = new ArrayList<>();
List<String> noDupe = new ArrayList<>();
for (ClassNode cn : nodeList)
{
ClassWriter cw = new ClassWriter(0);
@ -326,7 +327,7 @@ public class JarUtils
* @param nodeList The loaded ClassNodes
* @param dir the exact jar output path
*/
public static void saveAsJarClassesOnlyToDir(ArrayList<ClassNode> nodeList, String dir) {
public static void saveAsJarClassesOnlyToDir(List<ClassNode> nodeList, String dir) {
try {
for (ClassNode cn : nodeList) {
ClassWriter cw = new ClassWriter(0);
@ -349,10 +350,10 @@ public class JarUtils
* @param nodeList The loaded ClassNodes
* @param path the exact jar output path
*/
public static void saveAsJar(ArrayList<ClassNode> nodeList, String path) {
public static void saveAsJar(List<ClassNode> nodeList, String path) {
try (FileOutputStream fos = new FileOutputStream(path);
JarOutputStream out = new JarOutputStream(fos)) {
ArrayList<String> noDupe = new ArrayList<>();
List<String> noDupe = new ArrayList<>();
for (ClassNode cn : nodeList) {
ClassWriter cw = new ClassWriter(0);
cn.accept(cw);

View file

@ -16,6 +16,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import javax.imageio.ImageIO;
import javax.swing.SwingUtilities;
import org.apache.commons.lang3.StringUtils;
@ -57,7 +58,7 @@ public class MiscUtils
private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private static final String AN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private static final Random rnd = new Random();
private static final HashSet<String> createdRandomizedNames = new HashSet<>();
private static final Set<String> createdRandomizedNames = new HashSet<>();
/**
* Returns a random string without numbers
@ -189,7 +190,7 @@ public class MiscUtils
return path;
}
public static int fileContainersHash(ArrayList<ResourceContainer> resourceContainers) {
public static int fileContainersHash(List<ResourceContainer> resourceContainers) {
StringBuilder block = new StringBuilder();
for (ResourceContainer container : resourceContainers) {
block.append(container.name);