I am using the free Coverity Scan service for a learning project and I would like to model a few methods as either always throwing exceptions, or calling internally System.exit()
, hence non-returning, in order to get better results from Coverity's flow analysis.
For example:
class Foo {
// given these
Blarg fieldFromTheClass
void fail(String s, int a, int b) {
throw new DomainSpecificBlahBlahException(s, someFunction(a), someOtherFunction(a, b), fieldFromTheClass, collaborator.getBaz());
}
void fatal(Strin s) {
System.out.println("Fatal error: " + s);
System.exit(1);
}
// we should get 2 flags here
void test(int i) {
if (i%2==0) {
try {
fatal("foobar");
} catch (SecurityException se) {
// recovering from security manager - should be flagged as unreachable in normal circumstances
}
} else {
fail("baz", 1, 3);
}
doSomethingElse(); // unreachable
}
}
What would be the way to do that with a modelling file?
Also, are the Coverity annotations available in any public repository (i.e. Bintray or Central)?