We have a java program. I would like to track entry and returns of a few functions by calling appropriate profiler functions on the entry and returns of those functions.
Tracking a function entry is simple so won't be part of this discussion. However, return is a bit messy as we would have to add profiler code at every return points, and hence looking for suggestions how best we can do without cluttering the code.
In C++, it was easy, just create a local instance of a small trace class at entry of the function and the constructor and destructor of that trace class would take care of calling profiler function. However, java has no destructor (finalize won't work) so that approach is out of question.
Any suggestions/tips?