I'd like, given a certain object, to know where its class definition came from for logging purposes. Very likely this object will be anonymous inner types therefore the filename:line could help to investigate where a certain call is coming from.
Proxy.newProxyInstance(this.getClass().getClassLoader(),
new Class[] { MyClass.class },
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// Transparent proxy
final Object result = method.invoke(delegator, args);
System.out.println("Args[0] is of type "
+ args[0].getClass().getName()
+ " defined in "...);
});
Aucun commentaire:
Enregistrer un commentaire