How would you expose type of implementing class of an object regardless of whether it's real object or proxy ?
Here is example of the problem https://github.com/AsyncHttpClient/async-http-client/issues/1523
I thought I could intercept getClass
call in proxy but then I realized:
1) proxy intercepts only calls to interfaces defined as parameter to Proxy.newProxyInstance
;
2) I can't override getClass
in my interface because it's final.
I can of course add my own getImplementingClass
to my interface and use it everywhere instead of instanceof
but it looks hacky.
I can and know how to get class of invocation handler. But it (ReleasePermitOnComplete) is different from implementing class (WebSocketUpgradeHandler). Thus this question is more design question than simple question about how dynamic proxies work.
Ideas ?