Menu

#12 Incorrect results in case of nested try/catch

open
nobody
None
5
2011-04-08
2011-04-08
Anonymous
No

Example of code to profile:

package test4jip;
public class Main {
public static void main(String[] args) {
test();
}
private static void test() {
try {
try {
throwAnException();
} catch (Exception e) {
throw e;
}
} catch (Exception e) {
}
}
private static void throwAnException() throws Exception {
throw new Exception();
}
}

Profile result incorrectly says that method Main:main was executed 3 times:
Time Percent
----------------- ---------------
Count Total Net Total Net Location
===== ===== === ===== === =========
3 3,8 3,6 100,0 95,8 +--Main:main (test4jip)
1 0,2 0,1 4,2 2,3 | +--Main:test (test4jip)
1 0,1 0,1 1,9 1,9 | | +--Main:throwAnException (test4jip)

Expected outcome: Count for method Main:main is 1.

Discussion


Log in to post a comment.