Is it possible to listen to a method execution of an instance or all instances of a class, without modifying their code ?
Something like:
someInstance.addMethodExecutionListener('methodName', handler);
SomeClass.addMethodExecutionListener('methodName', handler);
It would be for logging purposes…
What you’re asking about is a small subset of what you can do with Aspect Oriented Programming. It’s not supported in plain Java and its implementations, but it’s the central reason for AspectJ.