I am using following code for generating proxy object
1) If i pass target (of type Class) as a class that extends one class that in turns implements one interface i.e the target indirectly implements the interface thru extended class
then i get class cast exception
where as if i directly implement the interface in target class then every one is happy..
what could be the problem?
2) is there a way to tell proxy object to monitor selected methods? example if i have foo and boo method in proxy object , i have to monitor only foo,currently i am doing it using if method==foo in invoke method, but is there any cleaner way?
All desirable things in life are either illegal, banned, expensive or married to someone else !!!
1: Class.getInterfaces() returns only directly implemented interfaces, not ones implemented via inheritance. If you check its javadocs, you'll see 'The order of the interface objects in the array corresponds to the order of the interface names in the implements clause of the declaration of the class represented by this object.'.
2: I know of no 'cleaner' way - isn't this how proxies and invocation handlers are supposed to work according to the documentation?
Joined: Feb 10, 2001
1. :- hmmm I may be only option is to mention the interface directly instead of using getInterfaces
2. :- Yeha I agree they are supposed to work that way but i was wondering if there is some way like get proxy and now add filter.. but seems there is no way..