javassist
javassist copied to clipboard
ProxyFactory doesn't work when used from Kotlin
I'm wondering whether ProxyFactory
is expected to work when used from Kotlin. I'm trying unsuccessfully to make this real simple test pass:
class ProxyFactoryKotlinTest {
open class LongLoader {
fun load(): Long {
return 1
}
}
fun <T> proxy(klass: Class<T>): T {
val proxyFactory = ProxyFactory()
proxyFactory.superclass = klass
val handler =
MethodHandler { _: Any?, _: Method, _: Method?, _: Array<Any?> ->
2L
}
return klass.cast(
proxyFactory.create(
arrayOf(),
arrayOf(),
handler
)
)
}
@Test
fun test() {
assertEquals(2, proxy(LongLoader::class.java).load())
}
}
Is it test setup or is it an issue with using ProxyFactory
from Kotlin?