saveAsJar Should Throw Exceptions

This commit is contained in:
Konloch 2024-10-05 00:21:07 -06:00
parent cf92749337
commit 471ae44864

AI 샘플 코드 생성 중입니다

Loading...
5 changed files with 65 additions and 27 deletions

View File

@ -27,6 +27,7 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
/**
* Whenever a key is pressed on the swing UI it should get logged here
@ -120,9 +121,19 @@ public class GlobalHotKeys
BytecodeViewer.updateBusyStatus(true);
Thread jarExport = new Thread(() ->
{
try
{
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), file.getAbsolutePath());
}
catch (IOException ex)
{
BytecodeViewer.handleException(ex);
}
finally
{
BytecodeViewer.updateBusyStatus(false);
}
}, "Jar Export");
jarExport.start();
}

View File

@ -31,6 +31,7 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@ -108,9 +109,12 @@ public class APKExport implements Exporter
return;
Thread saveThread = new Thread(() ->
{
try
{
BytecodeViewer.updateBusyStatus(true);
final String input = TEMP_DIRECTORY + FS + MiscUtils.getRandomizedName() + ".jar";
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
Thread buildAPKThread = new Thread(() ->
@ -120,6 +124,12 @@ public class APKExport implements Exporter
}, "Process APK");
buildAPKThread.start();
}
catch (IOException ex)
{
BytecodeViewer.updateBusyStatus(false);
BytecodeViewer.handleException(ex);
}
}, "Jar Export");
saveThread.start();

View File

@ -29,6 +29,7 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import static the.bytecode.club.bytecodeviewer.Constants.FS;
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
@ -72,9 +73,12 @@ public class DexExport implements Exporter
return;
Thread saveAsJar = new Thread(() ->
{
try
{
BytecodeViewer.updateBusyStatus(true);
final String input = TEMP_DIRECTORY + FS + MiscUtils.getRandomizedName() + ".jar";
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
Thread saveAsDex = new Thread(() ->
@ -85,6 +89,12 @@ public class DexExport implements Exporter
}, "Process DEX");
saveAsDex.start();
}
catch (IOException ex)
{
BytecodeViewer.updateBusyStatus(false);
BytecodeViewer.handleException(ex);
}
}, "Jar Export");
saveAsJar.start();

View File

@ -28,6 +28,7 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
/**
* @author Konloch
@ -64,9 +65,19 @@ public class ZipExport implements Exporter
BytecodeViewer.updateBusyStatus(true);
Thread saveThread = new Thread(() ->
{
try
{
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), file.getAbsolutePath());
}
catch (IOException ex)
{
BytecodeViewer.handleException(ex);
}
finally
{
BytecodeViewer.updateBusyStatus(false);
}
}, "Jar Export");
saveThread.start();

View File

@ -405,7 +405,7 @@ public class JarUtils
* @param nodeList The loaded ClassNodes
* @param path the exact jar output path
*/
public static void saveAsJar(List<ClassNode> nodeList, String path)
public static void saveAsJar(List<ClassNode> nodeList, String path) throws IOException
{
try (FileOutputStream fos = new FileOutputStream(path);
JarOutputStream out = new JarOutputStream(fos))
@ -448,9 +448,5 @@ public class JarUtils
fileCollisionPrevention .clear();
}
catch (IOException e)
{
BytecodeViewer.handleException(e);
}
}
}