- Index the classes and interfaces in your body of source and .class files, according to what they extend or implement. If A extends B which extends C which implements D, A should appear in the set of classes for all of B, C, and D.
- Starting from each method, initializer, static initializer block etc., find each constructor or method it might call. Create a set of called methods that includes the corresponding method in each subclass. If you call D's
get(int)
method you must include the corresponding methods in A, B, and C. You can find them using the index from Step 1.
- Starting from a method of interest, such as the main method or methods, form the list of all methods and constructors that might be called directly or indirectly. In effect, "indirectly calls" is the transitive closure of the relation build in step 2.
- Examine each possibly called method or constructor in the result of step 3. For each throw statement, report the type of the operand.
I will be very, very surprised if there is a benefit from this that justifies the cost.
Here's one example of a problem area. If you use the HashMap
get()
method, you use the Object
equals()
and hashCode()
methods. Every class directly or indirectly extends Object
, so the argument type for any throw statement in any equals()
or hashCode()
method is on the list.