Skip to content

Commit

Permalink
Remove test field on FernFlowerDecompiler generateMainMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
Bl3nd committed Oct 18, 2024
1 parent 756c823 commit 00340ec
Showing 1 changed file with 37 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public FernFlowerDecompiler()

private String[] inners;
private final List<File> innerFiles = new ArrayList<>();

@Override
public String decompileClassNode(ClassNode cn, byte[] bytes)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -248,31 +254,31 @@ private List<String> 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)
Expand Down

0 comments on commit 00340ec

Please sign in to comment.