0
그래서이 클래스가 있는데 어떤 메서드가 호출되었는지 인쇄하고 싶습니다. 내가 실행할 때 trace와 main 만 출력하지만 method1과 method2는 출력하지 않습니다. main에서 호출 한 method1 및 method2를 인쇄 할 수 있도록 어떻게 변경합니까?완료된 메서드를 포함한 스택 추적 인쇄
public class SomeClass
{
public void method1() {}
public void method2() {}
public static void main(String args[]) throws Throwable
{
SomeClass c = new SomeClass();
c.method1();
c.method2();
SomeClass.trace();
}
public static void trace() throws Throwable
{
Throwable t = new Throwable();
StackTraceElement[] stack = t.getStackTrace();
for(StackTraceElement s : stack)
System.out.println(s.getMethodName());
}
}
그런 다음 설명합니다. 빠른 답변에 감사드립니다. – user3210906