Skip to content

Commit

Permalink
Merge pull request #299 from leibnitz27/tidy-structured-finally
Browse files Browse the repository at this point in the history
Tidy prev commit
  • Loading branch information
leibnitz27 committed Apr 1, 2022
2 parents 3c0969b + 5eed894 commit c69ed17
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
@@ -0,0 +1,21 @@
/*
* Decompiled with CFR.
*/
package org.benf.cfr.tests;

public class TryTest1 {
public void test1() {
try {
try {
System.out.print(3);
throw new NoSuchFieldException();
} catch (NoSuchFieldException noSuchFieldException) {
System.out.print("Finally!");
}
} catch (Throwable throwable) {
System.out.print("Finally!");
throw throwable;
}
System.out.print(5);
}
}
5 changes: 5 additions & 0 deletions decompilation-test/test-specs/classes.xml
Expand Up @@ -28,4 +28,9 @@
<name>EnumTestEmpty</name>
<label>13</label>
</class>
<class>
<path>precompiled_tests/java_10/org/benf/cfr/tests</path>
<name>TryTest1</name>
<label>10</label>
</class>
</classes>
Expand Up @@ -14,7 +14,6 @@
import org.benf.cfr.reader.util.collections.ListFactory;
import org.benf.cfr.reader.util.output.Dumper;

import java.util.Iterator;
import java.util.List;

public class StructuredTry extends AbstractStructuredStatement {
Expand Down Expand Up @@ -78,15 +77,12 @@ public Dumper dump(Dumper dumper) {
dumper.separator(")");
}
tryBlock.dump(dumper);
dumper.removePendingCarriageReturn().separator(" ");
for (Iterator<Op04StructuredStatement> it = catchBlocks.iterator(); it.hasNext();) {
Op04StructuredStatement catchBlock = it.next();
for (Op04StructuredStatement catchBlock : catchBlocks) {
dumper.removePendingCarriageReturn().separator(" ");
catchBlock.dump(dumper);
if (it.hasNext() || finallyBlock != null) {
dumper.removePendingCarriageReturn().separator(" ");
}
}
if (finallyBlock != null) {
dumper.removePendingCarriageReturn().separator(" ");
finallyBlock.dump(dumper);
}
return dumper;
Expand Down

0 comments on commit c69ed17

Please sign in to comment.