mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 15:53:46 +00:00
Use only getDeclaredMethod/getDeclaredConstructor instead. The reason is that getMethod/getConstructor only finds public-API (public or protected on JVM) declarations, and to determine if a declaration is public-API in the class file we used isPublicInBytecode, which was trying to load annotations on the declaration to see if it was InlineOnly, and that required lots of time-consuming actions and worsened the stack trace (as can be seen e.g. in KT-27878). In fact, the implementation of Class.getMethod is not supposed to do anything complicated except loading annotations from each superclass and superinterface of the given class. Doing it in our codebase simplifies implementation and probably improves performance
28 lines
456 B
Kotlin
Vendored
28 lines
456 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// WITH_REFLECT
|
|
|
|
import kotlin.reflect.jvm.javaMethod
|
|
import kotlin.test.assertEquals
|
|
|
|
interface A1 {
|
|
fun a1()
|
|
}
|
|
|
|
interface A2 {
|
|
fun a2()
|
|
}
|
|
|
|
interface B1 : A1
|
|
interface B2 : A1, A2
|
|
|
|
interface C : B2
|
|
|
|
abstract class D : B1, C
|
|
|
|
fun box(): String {
|
|
assertEquals("public abstract void A1.a1()", D::a1.javaMethod!!.toString())
|
|
assertEquals("public abstract void A2.a2()", D::a2.javaMethod!!.toString())
|
|
|
|
return "OK"
|
|
}
|