Ideally, all mocking should be handled by either OverrideMock or
StaticReplacementMock. However, even in such cases, we would not be able
to get mocks from classes that are not instrumented (eg, other Java API
classes we do not mock). In theory, we should mock all of them. The
problem raises for "Exceptions", as they are used everywhere, and would
require to mock the full Java API (which is not going to happen...).
Solution is, beside using OverrideMock for them, to also a further static
replacement (implemented in this method).
Note: why not just using static replacement instead of OverrideMock?
Because static replacement will not work if an exception instance is used
in a non-instrumented class, whereas OverrideMock would. Still, it could
be tedious to prepare OverrideMock for every single type of exception, so
the static replacement here could be a temporary workaround