Package-level declarations

Proxy creation methods.

Proxies work like the Java Proxy - they are anonymous objects that implement an interface using a "function handler" lambda for all method calls. A call to a proxy creation method is transformed into an anonymous object instance by the compiler plugin. All the arguments are calculated at compilation time.

Because of this, uses of this function can potentially add a significant amount of binary size. This is based on the number of appearances of proxy(), etc. in your code and how many members and parameters the argument has, not how many times it is invoked. If you find yourself repeatedly creating proxies for the same class, consider using proxyFactory, which has a constant binary overhead per factory invocation.

Types

Link copied to clipboard
class ProxyableInspektion<T : Any>(val inspektion: Inspektion<T>, factory: (ProxyHandler) -> T)

An Inspektion of a class, and a method for creating proxies of it.

Link copied to clipboard
fun interface ProxyHandler

A handler for calls to Inspekt proxies. Will be called for all method or property accessors on the proxy object.

Link copied to clipboard
sealed class SuperCall

The function call being handled by the proxy. Includes both the original function (superFun) and the call's args.

Functions

Link copied to clipboard
fun <T : Any> inspektAndProxy(@ReferenceLiteral(mustBeInterface = true) toImplement: KClass<T>, @StringLiteral name: String? = null): ProxyableInspektion<T>

Create an Inspektion and a proxy object factory, for proxies that implements T and responds to all method or accessor calls using the handler passed to the factory. toImplement must be a class reference literal of an interface.

Link copied to clipboard
fun <T : Any> proxy(@ReferenceLiteral(mustBeInterface = true) toImplement: KClass<T>, @StringLiteral name: String? = null, handler: ProxyHandler): T

Create a proxy object that implements T and responds to all method or accessor calls using handler. toImplement must be a class reference literal of an interface. The resulting object will implement toImplement.

Link copied to clipboard
fun <T : Any> proxyFactory(@ReferenceLiteral(mustBeInterface = true) toImplement: KClass<T>, @StringLiteral name: String? = null): (ProxyHandler) -> T

Create a proxy object factory, for proxies that implements T and responds to all method or accessor calls using the handler passed to the factory. toImplement must be a class reference literal of an interface. The resulting object will implement toImplement.