KT-45777: Snapshot Java classes using ASM analysis directly

This is faster than the current approach which creates
`JavaClassDescriptor`s, converts them to protos, and then snapshots
these protos.

- Refactor unit tests to faciliate further changes
- moves test data to a directory that matches the tests' package name
- moves expected snapshots to a separate directory
- adds public and private fields/properties to sample class
- Compute changes between ASM-based Java class snapshots
- Don't collect members of an added Java class as changes
as it's enough to report the name of the added Java class as changed (we
also do that for added Kotlin classes and Kotlin/Java removed classes).
- Add unit tests for impact analysis in advance
- Compute impacted symbols of changed symbols
Also do not collect added classes/class members as they don't impact
recompilation.
-Use ClassId when computing Java class changes
It is more precise than JvmClassName, which can be ambiguous around the
`$` character (e.g., ClassId "com/example/A$B.C" and "com/example/A.B$C"
both have the same JvmClassName "com/example/A$B$C").
- Compute impacted set of changed symbols across Kotlin and Java
- Add unit tests for impact analysis across Kotlin and Java
- Compute supertypes of Kotlin classes during snapshotting
- Handle inner classes when computing list of changed symbols.
For the reported symbols, always check all options:
class member, inner class, top level class, top level member.

Test: IncrementalJavaChangeClasspathSnapshotIT.testAddingInnerClass
This commit is contained in:
Hung Nguyen
2021-10-04 10:37:24 +01:00
committed by nataliya.valtman
parent 271368ac53
commit bd7c2ae6d7
137 changed files with 2139 additions and 1603 deletions
@@ -7,13 +7,12 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
import javax.tools.ToolProvider
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class JavaClassNameTest {
@@ -73,15 +72,7 @@ class JavaClassNameTest {
}
val classesDir = tmpDir.newFolder()
val compiler = ToolProvider.getSystemJavaCompiler()
compiler.getStandardFileManager(null, null, null).use { fileManager ->
val compilationTask = compiler.getTask(
null, fileManager, null,
listOf("-d", classesDir.path), null,
fileManager.getJavaFileObjectsFromFiles(listOf(sourceFile))
)
assertTrue(compilationTask.call(), "Failed to compile '$className'")
}
KotlinTestUtils.compileJavaFiles(listOf(sourceFile), listOf("-d", classesDir.path))
return classesDir.walk().filter { it.isFile }
.sortedBy { it.path.substringBefore(".class") }