Cleanup On Decompiler Failure

This commit is contained in:
Konloch 2024-10-02 12:12:43 -06:00
parent b69389cc5f
commit 17e1d621fe

AI 샘플 코드 생성 중입니다

Loading...

View File

@ -82,12 +82,13 @@ public class ProcyonDecompiler extends AbstractDecompiler
@Override @Override
public String decompileClassNode(ClassNode cn, byte[] bytes) public String decompileClassNode(ClassNode cn, byte[] bytes)
{ {
TempFile tempFile = null;
String exception; String exception;
try try
{ {
final TempFile tempFile = TempFile.createTemporaryFile(false, ".class"); tempFile = TempFile.createTemporaryFile(false, ".class");
final File tempClassFile = tempFile.getFile(); File tempClassFile = tempFile.getFile();
//write the ClassNode bytes to the temp file //write the ClassNode bytes to the temp file
try (FileOutputStream fos = new FileOutputStream(tempClassFile)) try (FileOutputStream fos = new FileOutputStream(tempClassFile))
@ -128,6 +129,10 @@ public class ProcyonDecompiler extends AbstractDecompiler
exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw; exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
} }
//delete all temporary files
if(tempFile != null)
tempFile.delete();
return PROCYON + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL return PROCYON + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL
+ TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception; + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception;
} }