[Checkers] Question about the flow algorithm
Adam Warski
adam at warski.org
Sat Apr 4 14:16:12 EDT 2009
Hello,
I've commited an implementation of the changes I wrote here about to
the typestate checker's GIT repository:
http://github.com/adamw/jsr308-typestate-checker/blob/8b6eef49eaa2fa14642a4d09668d0bab02627957/src/checkers/flow/MainFlow.java
lines 619 and below. The method has some comments so hopefully you'll
understand it :). The "MainFlow" is a simplified version of your
"Flow" class, and the try-catch-finally handling is a bit tailored
towards the typestate checker, but maybe you could modify/reuse it in
some way in the checkers framework.
The method makes the distinction between "dead" and "alive" catches,
as I wrote in my previous mails. It also evaluates the finally for two
cases: "dead" catches + exception bypass, and "alive" cathces + no
exceptions at all. Also, exceptions thrown in catches are properly
handled. This I think covers the cases possible.
The algorithm can of course be still much improved, as it's very
conservative on nested exceptions handling, meaning that it assumes
that every exception can bypass the first catch and propagate to the
second one, etc. The way to improve would be of course to check what
exceptions are caught (for example if "Exception" is caught, than the
exception won't be propagated for sure; unless it's an Error, but
that's serious system trouble, not an application problem). Also, it
could be checked what exceptions do the methods throw, and only update
the bits for the appropriate catch blocks.
Adam
More information about the checkers
mailing list