I want to write a simple java agent which can print the name of a method called by the java program instrumented.
For example, my java program I want to instrument
I do not think it is easy.
The only option I can think of would be implementing a class loader and replacing the original classes with stubs created by you (Hibernate / JPA does something like that for lazy loading). The stubs would perform the operation you require and then call the original classes to perform the work. It would mean a heavy burden (reflection calls are not cheap).