I wrote an utility to create a CFG (Control Flow Graph) for a java method whose nodes are basic blocks instead of instructions.
I could not consider exception throws to be edges in CFG. The reasons are that:
- Every instruction in try block can potentially throw exceptions / errors which can be handled by any of the nesting try-catch blocks. If we consider exception throws as edges, the number of paths to process increases drastically, and so will the number of nodes in CFG.
- We need to know the inheritance hierarchy for exceptions before we can decide what jumps are possible.
How do static code analyzers solve this problem?
I am stuck at this point. If I have to proceed, how should I go about it?
Edit: in my case, I can limit support to those use cases which can specify where and which exceptions are thrown. This solved my second problem. I would still like to know how generic static code analysers manage this.