I want to trace all invocations of methods from a Foo class. Another class that would override all the methods from Foo like this…
@Override
public void blah() {
System.out.println("blah()");
super.blah();
}
…would do – but do I really need to override them all (over 100 methods)?
Can this be done in some smarter way, e.g., using reflection?
EDIT: To clarify – Foo is a JNI interface to a native library, and I need this to save all the calls to a file, to generate C code that does exactly what I did from Java.
First, if you have 100 methods in a class it is a prime candidate for refactoring.
Then – you can make a proxy (using CGLIB or javassist) around the object, and whenever a method is invoked, report the invocation.