Skip to content

What is a proxy

Jonathan edited this page Feb 4, 2018 · 1 revision

Proxy is a wrapper or agent to access real object behind scenes¹, in Java, there is a native proxy generator², but Java Proxy Generator has some limitations:

  • They can only have super interfaces
    • Essentially, Proxies interfaces to something (note the 'interfaces' word), but in some special cases, we need to extend a class (for lazy evaluation for example).
  • They need reflection
    • This introduces a little overhead to invocations, JIT can optimize it, but JIT would do better if it was a simple direct invocation.
  • Invocation of super method
    • Super invocations is not possible without hacks (which may not work at all with access exceptions).

KoresProxy does not have these limitations and also allow user to customize proxy classes.

Reference

¹Wikipedia ²Proxy

Clone this wiki locally