Fortunately, IntelliJ IDEA has this powerful structural search feature. Let's explain how to use it in order to find those possible bottlenecks. Structural search is powerful as it allows you to describe "patterns" of code to match. No matter the indentation, no matter the statements, you'll just lookup for structural matches.
In our case, you need to look for something that "looks like" this :
for () {
try {
} catch () {
}
}
The corresponding structural search pattern will be :
for ($decl$;$condition$;$increment$) {
$beforeStatements$;
try {
$TryStatement$;
} catch ($exceptionType$ $ex$) {
$CatchStatement$;
}
$afterStatements$;
}
To use this, either click on the "search structurally" item in the search menu, or press Ctrl+Shift+S and enter the pattern :
Now click on "Find" and you'll probably find some of those nasty constructs. The previous patterns works for classical for loops, you need to tune it to work for Java 5 for each constructs, and don't forget while loops too.