Java 動態取得當下所執行的方法名稱

public void methodA() {
    String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
    System.out.println(methodName); //methodA
}

public void methodB() {
    String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
    System.out.println(methodName); //methodB
}