From 00340ecd1c0b6b0683303d2658871f73c5d110d3 Mon Sep 17 00:00:00 2001 From: Cody <6558800+Bl3nd@users.noreply.github.com> Date: Thu, 17 Oct 2024 21:22:13 -0600 Subject: [PATCH] Remove test field on FernFlowerDecompiler generateMainMethod --- .../impl/FernFlowerDecompiler.java | 68 ++++++++++--------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java index 3c2398eac..71ca66b93 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java @@ -59,6 +59,7 @@ public FernFlowerDecompiler() private String[] inners; private final List innerFiles = new ArrayList<>(); + @Override public String decompileClassNode(ClassNode cn, byte[] bytes) { @@ -88,19 +89,24 @@ else if (innerClasses.get(i).outerName == null) } } - for (ResourceContainer container :BytecodeViewer.resourceContainers.values()) { + for (ResourceContainer container : BytecodeViewer.resourceContainers.values()) + { container.resourceClasses.forEach((s, classNode) -> { - for (String innerClassName : inners) { - if (s.equals(innerClassName)) { + for (String innerClassName : inners) + { + if (s.equals(innerClassName)) + { innerTempFile.set(TempFile.createTemporaryFile(true, ".class")); File tempInputClassFile2 = innerTempFile.get().getFile(); - try (FileOutputStream fos = new FileOutputStream(tempInputClassFile2)) { + try (FileOutputStream fos = new FileOutputStream(tempInputClassFile2)) + { fos.write(ASMUtil.nodeToBytes(classNode)); } catch (IOException e) { throw new RuntimeException(e); - } finally + } + finally { innerFiles.add(tempInputClassFile2); innerTempFile.get().markAsCreatedFile(tempInputClassFile2); @@ -135,7 +141,7 @@ else if (innerClasses.get(i).outerName == null) { ExternalResources.getSingleton().getJavaCommand(true), "-jar", ExternalResources.getSingleton().findLibrary("fernflower") - }, generateMainMethod(tempInputClassFile.getAbsolutePath(), "", tempFile.getParent().getAbsolutePath()) + }, generateMainMethod(tempInputClassFile.getAbsolutePath(), tempFile.getParent().getAbsolutePath()) ), false); } else @@ -170,7 +176,7 @@ else if (innerClasses.get(i).outerName == null) finally { //cleanup temp files - if(tempFile != null) + if (tempFile != null) tempFile.cleanup(); if (innerTempFile.get() != null) @@ -202,7 +208,7 @@ public void decompileToZip(String sourceJar, String zipName) try { - ConsoleDecompiler.main(generateMainMethod(tempInputJarFile.getAbsolutePath(), "", TEMP_DIRECTORY + "./temp/")); + ConsoleDecompiler.main(generateMainMethod(tempInputJarFile.getAbsolutePath(), TEMP_DIRECTORY + "./temp/")); } catch (StackOverflowError | Exception ignored) { @@ -248,31 +254,31 @@ private List generate(String className, String folder) return strings; } - private String[] generateMainMethod(String className, String test, String folder) + private String[] generateMainMethod(String className, String folder) { return new String[] - { - "-rbr=" + ffOnValue(BytecodeViewer.viewer.rbr.isSelected()), - "-rsy=" + ffOnValue(BytecodeViewer.viewer.rsy.isSelected()), - "-din=" + ffOnValue(BytecodeViewer.viewer.din.isSelected()), - "-dc4=" + ffOnValue(BytecodeViewer.viewer.dc4.isSelected()), - "-das=" + ffOnValue(BytecodeViewer.viewer.das.isSelected()), - "-hes=" + ffOnValue(BytecodeViewer.viewer.hes.isSelected()), - "-hdc=" + ffOnValue(BytecodeViewer.viewer.hdc.isSelected()), - "-dgs=" + ffOnValue(BytecodeViewer.viewer.dgs.isSelected()), - "-ner=" + ffOnValue(BytecodeViewer.viewer.ner.isSelected()), - "-den=" + ffOnValue(BytecodeViewer.viewer.den.isSelected()), - "-rgn=" + ffOnValue(BytecodeViewer.viewer.rgn.isSelected()), - "-bto=" + ffOnValue(BytecodeViewer.viewer.bto.isSelected()), - "-nns=" + ffOnValue(BytecodeViewer.viewer.nns.isSelected()), - "-uto=" + ffOnValue(BytecodeViewer.viewer.uto.isSelected()), - "-udv=" + ffOnValue(BytecodeViewer.viewer.udv.isSelected()), - "-rer=" + ffOnValue(BytecodeViewer.viewer.rer.isSelected()), - "-fdi=" + ffOnValue(BytecodeViewer.viewer.fdi.isSelected()), - "-asc=" + ffOnValue(BytecodeViewer.viewer.asc.isSelected()), - "-ren=" + ffOnValue(BytecodeViewer.viewer.ren.isSelected()), - className, test, folder - }; + { + "-rbr=" + ffOnValue(BytecodeViewer.viewer.rbr.isSelected()), + "-rsy=" + ffOnValue(BytecodeViewer.viewer.rsy.isSelected()), + "-din=" + ffOnValue(BytecodeViewer.viewer.din.isSelected()), + "-dc4=" + ffOnValue(BytecodeViewer.viewer.dc4.isSelected()), + "-das=" + ffOnValue(BytecodeViewer.viewer.das.isSelected()), + "-hes=" + ffOnValue(BytecodeViewer.viewer.hes.isSelected()), + "-hdc=" + ffOnValue(BytecodeViewer.viewer.hdc.isSelected()), + "-dgs=" + ffOnValue(BytecodeViewer.viewer.dgs.isSelected()), + "-ner=" + ffOnValue(BytecodeViewer.viewer.ner.isSelected()), + "-den=" + ffOnValue(BytecodeViewer.viewer.den.isSelected()), + "-rgn=" + ffOnValue(BytecodeViewer.viewer.rgn.isSelected()), + "-bto=" + ffOnValue(BytecodeViewer.viewer.bto.isSelected()), + "-nns=" + ffOnValue(BytecodeViewer.viewer.nns.isSelected()), + "-uto=" + ffOnValue(BytecodeViewer.viewer.uto.isSelected()), + "-udv=" + ffOnValue(BytecodeViewer.viewer.udv.isSelected()), + "-rer=" + ffOnValue(BytecodeViewer.viewer.rer.isSelected()), + "-fdi=" + ffOnValue(BytecodeViewer.viewer.fdi.isSelected()), + "-asc=" + ffOnValue(BytecodeViewer.viewer.asc.isSelected()), + "-ren=" + ffOnValue(BytecodeViewer.viewer.ren.isSelected()), + className, folder + }; } private String ffOnValue(boolean b)