Let's say I have a class Foo
and a method evilMethod
:
class Foo {
public void evilMethod() {
// do sth
}
}
Is there a way to write a test that would fail any time there is any invocation of this method in any class on the classpath? I mean, not when the method is invoked at runtime, but when it's declared in the code.
For example, the precense of this code in any class on the classpath should make the test fail:
if(false) {
Foo f = new Foo();
f.evilMethod(); // test fails because of that
}
What I want to achieve: I would like to annotate methods that should not be called in certain project, but need to be placed there for the use in another, and then write a test that makes sure annotated methods are not invoked anywhere indeed.