Don't create KClass and KPackage instances in <clinit>

This proved to be a fragile technique, which probably doesn't even improve
performance in most cases but has lots of unexpected problems: unconditional
initialization of reflection classes, increasing the size of the bytecode, bugs
with <clinit> in annotations on JVM 6, inability to support conversion of a
class from Kotlin to Java without recompiling clients which use it
reflectively, etc.

Original commit: a4732b442d
This commit is contained in:
Alexander Udalov
2015-10-06 21:55:49 +03:00
parent cfad31bba1
commit 00ca2c8bad
@@ -468,8 +468,8 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
// Check that outputs are located properly
val facadeWithA = findFileInOutputDir(findModule("module1"), "test/TestPackage.class")
val facadeWithB = findFileInOutputDir(findModule("module2"), "test/TestPackage.class")
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "<clinit>", "a", "getA")
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "<clinit>", "b", "getB", "setB")
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "a", "getA")
UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "b", "getB", "setB")
checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage"))
checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage"))