[New IC] Optimize Java class snapshotting with ASM ClassWriter

To snapshot a Java class (+ its fields and methods), previously we used
Gson to serialize a class field/method to a string via reflection, and
hash that string.

We now use an ASM ClassWriter to write a placeholder class containing
the field/method of interest and hash the bytecode of that class.

One experiment showed that this new approach is ~10 times faster than
the previous approach (140s down to 16s when snapshotting 600 jars).

Test: Updated expectation files for JavaClassSnapshotterTest unit tests
      + Existing integration tests to prevent regression

^KT-52141 In Progress
This commit is contained in:
Hung Nguyen
2022-04-21 16:43:58 +01:00
committed by teamcity
parent 5a0c3920a5
commit 9eb3c7ed76
8 changed files with 74 additions and 96 deletions
@@ -18,7 +18,6 @@ dependencies {
api(project(":compiler:backend.jvm.entrypoint"))
api(project(":kotlin-build-common"))
api(project(":daemon-common"))
implementation(commonDependency("com.google.code.gson:gson"))
compileOnly(intellijCore())
testApi(commonDependency("junit:junit"))
@@ -30,6 +29,7 @@ dependencies {
testApi(commonDependency("org.jetbrains.intellij.deps:log4j"))
testApi(commonDependency("org.jetbrains.intellij.deps:jdom"))
testImplementation(commonDependency("com.google.code.gson:gson"))
testRuntimeOnly(project(":kotlin-reflect"))
testRuntimeOnly(project(":core:descriptors.runtime"))
}