The closest you can come to this is using code coverage tools. Providing you have a full set of unit tests, they will allow you to identify, for example, which methods are never called. I can't recommend one library in particular but there are plenty available.
Require a method of an instantiated class to be called
-
24-06-2022 - |
Domanda
Let's say I have this code:
public class MyClass {
public void doSomething(int value) {
}
}
public class MyNewClass {
public static void main(String args[]) {
MyClass myClass = new MyClass();
}
}
Would it be possible to get a compiler error that doSomething(int)
from MyClass
has not been called in MyNewClass
? I know realistically you would put that method in the constructor but this question is out of curiosity.
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow