Skip to content

Commit

Permalink
style + add test sources
Browse files Browse the repository at this point in the history
  • Loading branch information
swissiety committed Feb 4, 2025
1 parent b7ae349 commit 33fb867
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
Binary file not shown.
38 changes: 38 additions & 0 deletions shared-test-resources/bugfixes/NestedTryCatchFlow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
public class NestedTryCatchFlow {
int test_nested_try_catch_2(int param) {
try {
try {
try {
if (param == 10)
return 0;
if (param == 20 || param == 25 || param == 27 || param == 28) {
throw new IllegalArgumentException("Illegal arguments provided");
}
if (param == 30) {
throw new IllegalStateException("Illegal state exception");
}
return 1;
} catch (IllegalArgumentException e) {
if (param == 25 || param == 27 || param == 28) {
throw new IllegalStateException("Illegal state exception 2");
}
return 2;
} catch (IllegalStateException e) {
return 3;
}
} catch (IllegalStateException e) {
if (param == 25) {
throw new ArrayIndexOutOfBoundsException();
}
if (param == 27) {
throw new IllegalArgumentException("Illegal arguments provided 2");
}
return 4;
}
} catch (ArrayIndexOutOfBoundsException e) {
return 5;
} catch (RuntimeException e) {
return 6;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,21 @@ public void initializeWith(
}

private static int getTrapApplicationComparator(
HashMap<Stmt, Integer> trapstmtToIdx, Trap trapA, Trap trapB) {
if (trapA.getEndStmt() == trapB.getEndStmt() && trapA.getBeginStmt() == trapB.getBeginStmt()) {
final Integer idxA = trapstmtToIdx.get(trapA.getHandlerStmt());
final Integer idxB = trapstmtToIdx.get(trapB.getHandlerStmt());
return idxA - idxB;
} else if (trapA.getEndStmt() == trapB.getEndStmt()) {
final Integer startIdxA = trapstmtToIdx.get(trapA.getBeginStmt());
final Integer startIdxB = trapstmtToIdx.get(trapB.getBeginStmt());
return startIdxB - startIdxA;
HashMap<Stmt, Integer> trapstmtToIdx, Trap trapA, Trap trapB) {
if (trapA.getEndStmt() == trapB.getEndStmt()) {
if (trapA.getBeginStmt() == trapB.getBeginStmt()) {
final Integer handlerIdxA = trapstmtToIdx.get(trapA.getHandlerStmt());
final Integer handlerIdxB = trapstmtToIdx.get(trapB.getHandlerStmt());
return handlerIdxA - handlerIdxB;
} else {
final Integer beginIdxA = trapstmtToIdx.get(trapA.getBeginStmt());
final Integer beginIdxB = trapstmtToIdx.get(trapB.getBeginStmt());
return beginIdxB - beginIdxA;
}
} else {
final Integer idxA = trapstmtToIdx.get(trapA.getEndStmt());
final Integer idxB = trapstmtToIdx.get(trapB.getEndStmt());
return idxA - idxB;
final Integer endIdxA = trapstmtToIdx.get(trapA.getEndStmt());
final Integer endIdxB = trapstmtToIdx.get(trapB.getEndStmt());
return endIdxA - endIdxB;
}
}

Expand Down

0 comments on commit 33fb867

Please sign in to comment.