#896: show exception in log frame, static final loggers added

This commit is contained in:
2015-05-22 11:29:27 +02:00
parent c8350b19bd
commit 39f35dec29
18 changed files with 116 additions and 86 deletions
@@ -127,6 +127,8 @@ import java.util.logging.Logger;
*/
public class CommandLineArgumentParser {
private static final Logger logger = Logger.getLogger(CommandLineArgumentParser.class.getName());
private static boolean commandLineMode = false;
private static String stdOut = null;
@@ -827,7 +829,7 @@ public class CommandLineArgumentParser {
swf.swfList = new SWFList();
swf.swfList.sourceInfo = sourceInfo;
} catch (IOException | InterruptedException ex) {
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
break;
@@ -1141,7 +1143,7 @@ public class CommandLineArgumentParser {
}
} catch (OutOfMemoryError | Exception ex) {
System.err.print("FAIL: Exporting Failed on Exception - ");
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
System.exit(1);
}
@@ -1174,7 +1176,7 @@ public class CommandLineArgumentParser {
System.err.println("File not found.");
}
} catch (IOException ex) {
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
System.exit(0);
@@ -1199,7 +1201,7 @@ public class CommandLineArgumentParser {
System.err.println("File not found.");
}
} catch (IOException ex) {
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
System.exit(0);
@@ -1217,10 +1219,10 @@ public class CommandLineArgumentParser {
} catch (FileNotFoundException ex) {
System.err.println("File not found.");
} catch (InterruptedException ex) {
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
} catch (IOException ex) {
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
System.exit(0);
@@ -1239,7 +1241,7 @@ public class CommandLineArgumentParser {
swf.saveTo(new BufferedOutputStream(fos));
}
} catch (IOException ex) {
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
System.exit(0);
@@ -1325,7 +1327,7 @@ public class CommandLineArgumentParser {
}
}
} catch (IOException ex) {
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
System.exit(0);
@@ -1365,7 +1367,7 @@ public class CommandLineArgumentParser {
System.err.println("File not found.");
}
} catch (IOException ex) {
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
System.exit(0);
@@ -1694,7 +1696,7 @@ public class CommandLineArgumentParser {
SWFSourceInfo sourceInfo = new SWFSourceInfo(null, args.pop(), null);
Main.parseSWF(sourceInfo);
} catch (Exception ex) {
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
System.exit(1);
}
System.exit(0);
@@ -68,6 +68,8 @@ import javax.swing.SpringLayout;
*/
public class GenericTagPanel extends JPanel implements ChangeListener {
private static final Logger logger = Logger.getLogger(GenericTagPanel.class.getName());
private final JEditorPane genericTagPropertiesEditorPane;
private final JPanel genericTagPropertiesEditPanel;
@@ -270,7 +272,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
addButtons.put(name, addButton);
}
} catch (IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(GenericTagPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
return propCount;
@@ -311,7 +313,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
Logger.getLogger(GenericTagPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
View.execInEventDispatch(() -> {
@@ -358,7 +360,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
Logger.getLogger(GenericTagPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
View.execInEventDispatch(() -> {
@@ -411,7 +413,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
value = ReflectionTools.newInstanceOf(field.getType());
field.set(obj, value);
} catch (InstantiationException | IllegalAccessException ex) {
Logger.getLogger(GenericTagPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
return 0;
}
} else {
@@ -480,7 +482,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
try {
f.set(t, f.get(assigned));
} catch (IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(GenericTagPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
}
@@ -553,7 +555,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
dependentLabel.setVisible(conditionMet);
dependentTypeLabel.setVisible(conditionMet);
} catch (AnnotationParseException ex) {
Logger.getLogger(GenericTagPanel.class.getName()).log(Level.SEVERE, "Invalid condition", ex);
logger.log(Level.SEVERE, "Invalid condition", ex);
}
}
if (!conditionMet) {
@@ -83,6 +83,8 @@ import javax.swing.tree.TreePath;
*/
public class GenericTagTreePanel extends GenericTagPanel {
private static final Logger logger = Logger.getLogger(GenericTagTreePanel.class.getName());
private JTree tree;
private Tag editedTag;
@@ -132,7 +134,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
try {
type = ReflectionTools.getValue(obj, field, index).getClass();
} catch (IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, "Fixing characters order failed, recursion detected.");
logger.log(Level.SEVERE, "Fixing characters order failed, recursion detected.");
return null;
}
SWFType swfType = field.getAnnotation(SWFType.class);
@@ -368,7 +370,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
ReflectionTools.setValue(obj, field, Array.newInstance(field.getType().getComponentType(), 0));
}
} catch (IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
}
@@ -445,7 +447,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
val = ReflectionTools.newInstanceOf(field.getType());
ReflectionTools.setValue(obj, field, index, val);
} catch (InstantiationException | IllegalAccessException ex) {
Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
return null;
}
}
@@ -532,7 +534,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
}
}
} catch (AnnotationParseException ex) {
Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
}
@@ -667,7 +669,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
editedTag = tag.cloneTag();
} catch (InterruptedException ex) {
} catch (IOException ex) {
Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
tree.setEditable(edit);
if (!edit) {
@@ -693,7 +695,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
try {
f.set(t, f.get(assigned));
} catch (IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
}
@@ -811,7 +813,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
continue;
}
} catch (AnnotationParseException | IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
}
@@ -70,6 +70,8 @@ import javax.swing.JPanel;
public final class ImagePanel extends JPanel implements MediaDisplay {
private static final Logger logger = Logger.getLogger(ImagePanel.class.getName());
private final List<MediaDisplayListener> listeners = new ArrayList<>();
private Timelined timelined;
@@ -516,7 +518,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
try {
setImage(new SerializableImage(ImageIO.read(new ByteArrayInputStream(data))));
} catch (IOException ex) {
Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
@@ -561,7 +563,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
try {
delayObject.wait(drawWaitLimit);
} catch (InterruptedException ex) {
Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
@@ -900,7 +902,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
}
}
} catch (LineUnavailableException | IOException | UnsupportedAudioFileException ex) {
Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, "Error during playing sound", ex);
logger.log(Level.SEVERE, "Error during playing sound", ex);
}
}
@@ -989,7 +991,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
nextFrame(thisTimer);
}
} catch (Exception ex) {
Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
};
+2 -2
View File
@@ -289,7 +289,7 @@ public class Main {
try {
result.add(worker.get());
} catch (CancellationException ex) {
Logger.getLogger(Main.class.getName()).log(Level.WARNING, "Loading SWF {0} was cancelled.", streamEntry.getKey());
logger.log(Level.WARNING, "Loading SWF {0} was cancelled.", streamEntry.getKey());
}
}
} else {
@@ -314,7 +314,7 @@ public class Main {
try {
result.add(worker.get());
} catch (CancellationException ex) {
Logger.getLogger(Main.class.getName()).log(Level.WARNING, "Loading SWF {0} was cancelled.", sourceInfo.getFileTitleOrName());
logger.log(Level.WARNING, "Loading SWF {0} was cancelled.", sourceInfo.getFileTitleOrName());
}
}
@@ -51,6 +51,8 @@ import javax.swing.text.BadLocationException;
*/
public class TextPanel extends JPanel implements TagEditorPanel {
private static final Logger logger = Logger.getLogger(TextPanel.class.getName());
private final MainPanel mainPanel;
private final SearchPanel<TextTag> textSearchPanel;
@@ -220,7 +222,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
break;
}
} catch (BadLocationException ex) {
Logger.getLogger(TextPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
}
@@ -244,7 +246,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
selected.replace(start - selStart, end - selStart, str);
} catch (BadLocationException ex) {
Logger.getLogger(TextPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
}
@@ -344,7 +346,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
try {
textTag.undo();
} catch (InterruptedException | IOException ex) {
Logger.getLogger(TextPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
textTag.getSwf().clearImageCache();
@@ -393,7 +395,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
saveText(false);
updateButtonsVisibility();
} catch (Exception ex) {
Logger.getLogger(TextPanel.class.getName()).log(Level.SEVERE, "Cannot auto-save text tag.", ex);
logger.log(Level.SEVERE, "Cannot auto-save text tag.", ex);
}
}
@@ -83,7 +83,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
@@ -779,8 +778,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
decompiledTextArea.gotoLine((int) ex.line);
decompiledTextArea.markError();
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
} catch (IOException | InterruptedException ex) {
//ignore
} catch (Throwable ex) {
Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
@@ -91,6 +91,8 @@ import jsyntaxpane.actions.ActionUtils;
public class ActionPanel extends JPanel implements SearchListener<ActionSearchResult>, TagEditorPanel {
private static final Logger logger = Logger.getLogger(ActionPanel.class.getName());
private MainPanel mainPanel;
public LineMarkedEditorPane editor;
@@ -327,7 +329,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
try {
asm.getASMSource(exportMode, writer, lastCode);
} catch (InterruptedException ex) {
Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
asm.removeDisassemblyListener(listener);
return new HighlightedText(writer);
@@ -749,7 +751,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
GraphDialog gf = new GraphDialog(mainPanel.getMainFrame().getWindow(), new ActionGraph(lastCode, new HashMap<>(), new HashMap<>(), new HashMap<>(), SWF.DEFAULT_VERSION), "");
gf.setVisible(true);
} catch (InterruptedException ex) {
Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
}
@@ -834,7 +836,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
src.setActions(actions);
} catch (InterruptedException ex) {
Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
@@ -858,11 +860,13 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
View.showMessageDialog(this, AppStrings.translate("message.action.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showCodeSavedMessage);
setDecompiledEditMode(false);
} catch (IOException ex) {
Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, "IOException during action compiling", ex);
logger.log(Level.SEVERE, "IOException during action compiling", ex);
} catch (ActionParseException ex) {
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
} catch (CompilationException ex) {
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
} catch (Throwable ex) {
logger.log(Level.SEVERE, null, ex);
}
}
@@ -61,6 +61,8 @@ import javax.swing.tree.TreePath;
*/
public class DumpTree extends JTree {
private static final Logger logger = Logger.getLogger(DumpTree.class.getName());
private final MainPanel mainPanel;
public class DumpTreeCellRenderer extends DefaultTreeCellRenderer {
@@ -193,7 +195,7 @@ public class DumpTree extends JTree {
byte[] data = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf().originalUncompressedData;
fos.write(data, (int) dumpInfo.startByte, (int) (dumpInfo.getEndByte() - dumpInfo.startByte + 1));
} catch (IOException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
}
@@ -220,7 +222,7 @@ public class DumpTree extends JTree {
}
repaint();
} catch (IOException | InterruptedException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
}
@@ -236,7 +238,7 @@ public class DumpTree extends JTree {
ais.dumpInfo = dumpInfo;
new ABC(ais, swf, null);
} catch (IOException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
repaint();
}
@@ -253,7 +255,7 @@ public class DumpTree extends JTree {
ais.dumpInfo = dumpInfo;
new AVM2Code(ais);
} catch (IOException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
logger.log(Level.SEVERE, null, ex);
}
repaint();
}