Can I cheaply call a Java method to get the name of the current method?
•
Java
Basically, I have a record statement in a method Whenever the method is called, I want to easily call the name of the method and append it to the logging statement This is done to minimize the number of hard - coded lines in my application Can it be cheaper?
Solution
No, it's not cheap and expensive, and the only way is to use the stacktrace method call Better just hard code
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码