以编程方式查找此类的所有方法在何处被调用或根本不被调用。
class blah {
void method1() {}
void method2() {}
}
class blahTest {
public static void main(String[] args) {
Class classToAnalyze = blah.class;
/* DO SOMETHING TO DETERMINE WHO IS CALLING blah CLASS AND IT'S METHODS
AND WHICH METHODS ARE NOT GETTING CALLED ANYWERE */
String sMethod = /* GET THIS VALUE FROM PREVIOUS OPERATION */
System.out.println("Method which is not getting called anywere: " + sMethod);
}
}
输出:
Method which is not getting called anywere:method2()
我如何从java以编程方式执行此操作?