Skip to content

Instantly share code, notes, and snippets.

View hjhjw1991's full-sized avatar
🛴

hjhjw1991 hjhjw1991

🛴
View GitHub Profile
@hjhjw1991
hjhjw1991 / MethodProxy.kt
Created June 15, 2020 08:36 — forked from crowjdh/MethodProxy.kt
Method proxy for Kotlin(verification necessary)
inline fun <reified T : Record> T.proxy(): T {
return Proxy.newProxyInstance(javaClass.classLoader,
arrayOf(Record::class.java),
RecordInvocationHandler(this)) as T
}
class RecordInvocationHandler<T: Record>(private val caller: T) : InvocationHandler {
override fun invoke(proxy: Any, method: Method, args: Array<Any>): Any? {
var result: Any? = null