Do not use getMethod/getConstructor in reflection

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
This commit is contained in:
Alexander Udalov
2018-10-30 18:35:45 +01:00
parent 2f72f68e1a
commit c5275f178a
9 changed files with 85 additions and 61 deletions
@@ -20130,6 +20130,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/reflection/mapping/methodsFromObject.kt");
}
@TestMetadata("methodsFromSuperInterface.kt")
public void testMethodsFromSuperInterface() throws Exception {
runTest("compiler/testData/codegen/box/reflection/mapping/methodsFromSuperInterface.kt");
}
@TestMetadata("openSuspendFun.kt")
public void testOpenSuspendFun() throws Exception {
runTest("compiler/testData/codegen/box/reflection/mapping/openSuspendFun.kt");