Skip to content

Commit a9591cb

Browse files
committed
When unable to find deobfuscator jar, show stack trace if there is one.
Log searching directory and which file we loaded from.
1 parent 17fec68 commit a9591cb

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

src/java/com/javadeobfuscator/deobfuscator/ui/SwingWindow.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,16 +1335,16 @@ private static void fallbackLoad(String path)
13351335
{
13361336
File file = new File(path);
13371337
if (!file.exists())
1338-
throw new FallbackException("Loading error", "Path specified does not exist.");
1338+
throw new FallbackException("Loading error", "Path specified does not exist.", null);
13391339
try
13401340
{
13411341
WrapperFactory.setupJarLoader(file);
13421342
} catch (IOException e)
13431343
{
1344-
throw new FallbackException("Loading error", "IOException while reading file.");
1344+
throw new FallbackException("Loading error", "IOException while reading file.", e);
13451345
} catch (InvalidJarException e)
13461346
{
1347-
throw new FallbackException("Loading error", "Invaild JAR selected. Note that old versions of deobfuscator are not supported!");
1347+
throw new FallbackException("Loading error", "Invaild JAR selected. Note that old versions of deobfuscator are not supported!", e);
13481348
}
13491349
deob = WrapperFactory.getDeobfuscator();
13501350
trans = WrapperFactory.getTransformers();

src/java/com/javadeobfuscator/deobfuscator/ui/util/FallbackException.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@
33
import java.awt.GridBagConstraints;
44
import java.awt.GridBagLayout;
55
import java.awt.Insets;
6+
import java.io.PrintWriter;
7+
import java.io.StringWriter;
68

79
import javax.swing.JButton;
810
import javax.swing.JFileChooser;
911
import javax.swing.JLabel;
1012
import javax.swing.JOptionPane;
1113
import javax.swing.JPanel;
14+
import javax.swing.JTextArea;
1215
import javax.swing.JTextField;
1316

1417
public class FallbackException extends Exception
1518
{
1619
public String path;
1720

18-
public FallbackException(String title, String msg)
21+
public FallbackException(String title, String msg, Throwable cause)
1922
{
23+
super(msg, cause);
24+
this.printStackTrace();
2025
JPanel fallback = new JPanel();
2126
fallback.setLayout(new GridBagLayout());
2227
GridBagConstraints gbc = new GridBagConstraints();
@@ -25,6 +30,12 @@ public FallbackException(String title, String msg)
2530
gbc.gridwidth = GridBagConstraints.REMAINDER;
2631
gbc.insets = new Insets(0, 0, 4, 0);
2732
fallback.add(new JLabel(msg), gbc);
33+
if (cause != null) {
34+
gbc.gridy++;
35+
JTextArea area = new JTextArea(getStackTrace(cause));
36+
area.setEditable(false);
37+
fallback.add(area, gbc);
38+
}
2839
gbc.gridy++;
2940
fallback.add(new JLabel("Select deobfuscator.jar to try again:"), gbc);
3041
gbc.gridy++;
@@ -53,4 +64,10 @@ public FallbackException(String title, String msg)
5364
System.exit(0);
5465
path = textField.getText();
5566
}
67+
68+
private static String getStackTrace(Throwable t) {
69+
StringWriter sw = new StringWriter();
70+
t.printStackTrace(new PrintWriter(sw));
71+
return sw.toString();
72+
}
5673
}

src/java/com/javadeobfuscator/deobfuscator/ui/wrap/Deobfuscator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public Config getConfig() throws FallbackException
6262
config = new Config(conf.newInstance());
6363
} catch (Exception e)
6464
{
65-
throw new FallbackException("Loading Problem", "Could not create Config instance.");
65+
throw new FallbackException("Loading Problem", "Could not create Config instance.", e);
6666
}
6767
}
6868
return config;

src/java/com/javadeobfuscator/deobfuscator/ui/wrap/Transformers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public List<Class<?>> getTransformers() throws FallbackException
5757
} catch (Exception e)
5858
{
5959
transformers.clear();
60-
throw new FallbackException("Loading Problem", "Failed to parse transformer list.");
60+
throw new FallbackException("Loading Problem", "Failed to parse transformer list.", e);
6161
}
6262
}
6363
return transformers;

src/java/com/javadeobfuscator/deobfuscator/ui/wrap/WrapperFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public static void setupJarLoader(boolean recursive)
7373
*/
7474
private static ByteLoader fromJar(File jar) throws IOException, InvalidJarException
7575
{
76+
System.out.println("Loading deobfuscator from jar: " + jar.getAbsolutePath());
7677
return new ByteLoader(readClasses(jar));
7778
}
7879

@@ -96,6 +97,7 @@ private static ByteLoader auto(boolean recurse)
9697
*/
9798
private static ByteLoader iter(File dir, boolean recurse)
9899
{
100+
System.out.println("Searching for deobfuscator in " + dir.getAbsolutePath());
99101
File[] files = dir.listFiles();
100102
// return if no files exist in the directory
101103
if (files == null)

0 commit comments

Comments
 (0)