#include <stdio.h>
void someFunc(void) {
printf("%s\n"), __func__);
}
Each time the function is called it will print:
someFunc
What is the java equivalent?
I have found
(new Exception()).getStackTrace()[0].getMethodName()
And
java.lang.Thread.currentThread().getStackTrace()[1].getMethodName()
But these just seem ridiculous, is there an easier way?
No, there's no easier way. As Java doesn't have a macro facility, there's nothing directly equivalent to the C++ version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With