createProxy

abstract fun <T> createProxy(clazz: Class<T>, classLoader: ClassLoader): T

Creates a dynamic proxy instance for the specified class using the provided class loader. This function is typically used for creating runtime proxies to enable reflective operations or to intercept method calls on the provided class type.

Return

A dynamic proxy instance of the specified class type T.

Parameters

T

The type of the class for which the proxy is created.

clazz

The Class object representing the class for which the proxy needs to be created.

classLoader

The ClassLoader to be used for defining the proxy class.

Throws

If the provided class or class loader is invalid, or if a proxy cannot be created.


open fun <T> createProxy(clazz: Class<T>): T

Creates a dynamic proxy instance for the specified class using its class loader. This method simplifies the creation of runtime proxies by leveraging the provided class.

Return

A dynamic proxy instance of the specified class type T.

Parameters

T

The type of the class for which the proxy is created.

clazz

The Class object representing the class for which the proxy needs to be created.

Throws

If the provided class or class loader is invalid, or if a proxy cannot be created.