Valentin Tihomirov
Valentin Tihomirov

Reputation: 1

Getting implemented interfaces from the proxy

You normally crate a proxy using

val proxy = Proxy.newProxyInstance(ClassLoader, Class<?>[] interfaces, handler) 

I am interested in the second parameter because I save created proxies in a list and I want to recreate the proxy with the same interfaces later on. Should I memorize interface classes along with the proxy list or there is a way to map proxy to its implementing interfaces, likewise Proxy.getInvocationHandler(proxy) does for handlers?

Upvotes: 1

Views: 1778

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170805

proxy.getClass.getInterfaces, since getInterfaces returns all implemented interfaces and the proxy class implements exactly the interfaces passed to newInstance.

Upvotes: 2

Related Questions