diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/As3ScriptReplaceException.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/As3ScriptReplaceException.java index a283ce9ee..92494b84a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/As3ScriptReplaceException.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/As3ScriptReplaceException.java @@ -15,6 +15,20 @@ public class As3ScriptReplaceException extends Exception { this.exceptionItems = exceptionItems; } + @Override + public String getMessage() { + StringBuilder sb = new StringBuilder(); + for (As3ScriptReplaceExceptionItem item : exceptionItems) { + sb.append(item.toString()).append("\r\n"); + } + return sb.toString(); + } + + @Override + public String getLocalizedMessage() { + return getMessage(); + } + public As3ScriptReplaceException(As3ScriptReplaceExceptionItem exceptionItem) { this.exceptionItems = new ArrayList<>(); this.exceptionItems.add(exceptionItem); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/As3ScriptReplaceExceptionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/As3ScriptReplaceExceptionItem.java index 771a29a72..52b722e54 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/As3ScriptReplaceExceptionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/As3ScriptReplaceExceptionItem.java @@ -41,4 +41,9 @@ public class As3ScriptReplaceExceptionItem { return col; } + @Override + public String toString() { + return (file != null ? "" + file : "") + (line != LINE_UNKNOWN ? ("(" + line + ")") : "") + (col != COL_UNKNOWN ? (" col: " + col) : ""); + } + } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/FFDecAs3ScriptReplacer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/FFDecAs3ScriptReplacer.java index 666c5355b..5843b240b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/FFDecAs3ScriptReplacer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/FFDecAs3ScriptReplacer.java @@ -67,6 +67,7 @@ public class FFDecAs3ScriptReplacer implements As3ScriptReplacerInterface { throw new As3ScriptReplaceException(new As3ScriptReplaceExceptionItem(null, ex.text, (int) ex.line)); } catch (CompilationException ex) { abc.script_info.get(oldIndex).delete(abc, false); + throw new As3ScriptReplaceException(new As3ScriptReplaceExceptionItem(null, ex.text, (int) ex.line)); } } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/DirectEditingTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/DirectEditingTest.java index 70319b3db..236fb968c 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/DirectEditingTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/DirectEditingTest.java @@ -27,11 +27,14 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.CodeFormatting; import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; +import com.jpexs.decompiler.flash.importers.As3ScriptReplaceException; +import com.jpexs.decompiler.flash.importers.As3ScriptReplacerFactory; import com.jpexs.decompiler.flash.importers.FFDecAs3ScriptReplacer; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.TranslateException; +import com.jpexs.helpers.Helper; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; @@ -55,6 +58,7 @@ public class DirectEditingTest extends FileTestBase { Configuration.autoDeobfuscate.set(false); Configuration.simplifyExpressions.set(false); Configuration._debugCopy.set(false); + Configuration.useFlexAs3Compiler.set(false); } public static final String TESTDATADIR = "testdata/directediting"; @@ -91,9 +95,11 @@ public class DirectEditingTest extends FileTestBase { try { en.toSource(htw, abc.script_info.get(s).traits.traits, new ConvertData(), ScriptExportMode.AS, false); String original = htw.toString(); - abc.replaceScriptPack(new FFDecAs3ScriptReplacer() /*TODO: test the otherone*/, en, original); + abc.replaceScriptPack(As3ScriptReplacerFactory.createFFDec() /*TODO: test the otherone*/, en, original); + } catch (As3ScriptReplaceException ex) { + fail("Exception during decompilation - file: " + filePath + " class: " + classPathString + " msg:" + ex.getMessage(), ex); } catch (Exception ex) { - fail("Exception during decompilation - file: " + filePath + " class: " + classPathString, ex); + fail("Exception during decompilation - file: " + filePath + " class: " + classPathString + " msg:" + ex.getMessage(), ex); throw ex; } } @@ -142,7 +148,7 @@ public class DirectEditingTest extends FileTestBase { } //TODO: try tu run it in debug flashplayer (?) } catch (Exception ex) { - fail("Exception during decompilation: " + filePath, ex); + fail("Exception during decompilation: " + filePath + ":" + ex.getMessage(), ex); } } diff --git a/libsrc/ffdec_lib/testdata/as3/as3.swf b/libsrc/ffdec_lib/testdata/as3/as3.swf index 3f191024a..9ec427d18 100644 Binary files a/libsrc/ffdec_lib/testdata/as3/as3.swf and b/libsrc/ffdec_lib/testdata/as3/as3.swf differ