diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 2a35cb4ee..7e8f6ed17 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -192,21 +192,24 @@ public class AVM2Graph extends Graph { List catchedExceptions = new ArrayList<>(); for (int e = 0; e < body.exceptions.length; e++) { if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (!body.exceptions[e].isFinally()) { - if (((body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { - catchedExceptions.clear(); - maxend = this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end); - catchedExceptions.add(body.exceptions[e]); - } else if (this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { - catchedExceptions.add(body.exceptions[e]); + //Add finally only when the list is empty + if (!body.exceptions[e].isFinally() || catchedExceptions.isEmpty()) { + if (!parsedExceptions.contains(body.exceptions[e])) { + if (((body.exceptions[e].end) > maxend)) { + catchedExceptions.clear(); + maxend = this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end); + catchedExceptions.add(body.exceptions[e]); + } else if (this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { + catchedExceptions.add(body.exceptions[e]); + } + } + } else if (body.exceptions[e].isFinally()) { + parsedExceptions.add(body.exceptions[e]); } } } if (catchedExceptions.size() > 0) { - /*if (currentLoop != null) { - //currentLoop.phase=0; - }*/ parsedExceptions.addAll(catchedExceptions); int endpos = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(catchedExceptions.get(0).end)); int endposStartBlock = code.adr2pos(catchedExceptions.get(0).end); @@ -328,6 +331,11 @@ public class AVM2Graph extends Graph { stopPart2.add(retPart); } catchedCommands.add(printGraph(localData2, stack, allParts, parent, npart, stopPart2, loops, staticOperation, path)); + if (catchedExceptions.get(e).isFinally()) { + catchedCommands.remove(catchedCommands.size() - 1); + catchedExceptions.remove(e); + e--; + } } GraphPart nepart = null; diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java index ee32ec70d..482967b87 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -897,6 +897,37 @@ public class ActionScript3Test extends ActionScriptTestBase { + "var b:Vector. = new [10,20,30];\r\n", false); } + public void testFinallyOnly() { + decompileMethod("testFinallyOnly", "var a:* = 5;\r\n" + + "try\r\n" + + "{\r\n" + + "a = 9;\r\n" + + "trace(\"intry\");\r\n" + + "}\r\n" + + "finally\r\n" + + "{\r\n" + + "trace(\"infinally\");\r\n" + + "}\r\n", false); + } + + @Test + public void testCatchFinally() { + decompileMethod("testCatchFinally", "var a:* = 5;\r\n" + + "try\r\n" + + "{\r\n" + + "a = 9;\r\n" + + "trace(\"intry\");\r\n" + + "}\r\n" + + "catch(e:*)\r\n" + + "{\r\n" + + "trace(\"incatch\");\r\n" + + "}\r\n" + + "finally\r\n" + + "{\r\n" + + "trace(\"infinally\");\r\n" + + "}\r\n", false); + } + @Test public void testOptionalParameters() { String methodName = "testOptionalParameters"; diff --git a/libsrc/ffdec_lib/testdata/as3/as3.swf b/libsrc/ffdec_lib/testdata/as3/as3.swf index a3d4e409c..af44e7251 100644 Binary files a/libsrc/ffdec_lib/testdata/as3/as3.swf and b/libsrc/ffdec_lib/testdata/as3/as3.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3/classes/Test.as b/libsrc/ffdec_lib/testdata/as3/classes/Test.as index 7652c8364..1aa504fff 100644 --- a/libsrc/ffdec_lib/testdata/as3/classes/Test.as +++ b/libsrc/ffdec_lib/testdata/as3/classes/Test.as @@ -887,5 +887,27 @@ var a:Vector.> = new Vector.>(); var b:Vector. = new [10,20,30]; } + + public function testFinallyOnly(){ + var a = 5; + try{ + a = 9; + trace("intry"); + }finally { + trace("infinally"); + } + } + + public function testCatchFinally(){ + var a = 5; + try{ + a = 9; + trace("intry"); + }catch(e){ + trace("incatch"); + }finally { + trace("infinally"); + } + } } } diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 626c22886..01c4f954d 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -23,15 +23,26 @@ import com.jpexs.decompiler.flash.SWFBundle; import com.jpexs.decompiler.flash.SWFSourceInfo; import com.jpexs.decompiler.flash.SearchMode; import com.jpexs.decompiler.flash.Version; +import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; +import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.CommandLineArgumentParser; import com.jpexs.decompiler.flash.console.ContextMenuTools; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.pipes.FirstInstance; import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame; +import com.jpexs.decompiler.flash.helpers.CodeFormatting; +import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; +import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; +import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.treeitems.SWFList; +import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Cache; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; @@ -63,6 +74,7 @@ import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.PrintWriter; import java.lang.reflect.Field; import java.net.InetSocketAddress; import java.net.Proxy; @@ -798,7 +810,7 @@ public class Main { ErrorLogFrame.createNewInstance(); } }); - + autoCheckForUpdates(); offerAssociation(); View.execInEventDispatch(new Runnable() { @@ -875,7 +887,7 @@ public class Main { } } Locale.setDefault(Locale.forLanguageTag(Configuration.locale.get())); - AppStrings.updateLanguage(); + AppStrings.updateLanguage(); try { Class cl = Class.forName("org.pushingpixels.substance.api.SubstanceLookAndFeel");