KT-45777: Reorganize unit test data for classpath snapshot feature

to make it easier to add more tests in the next commits.

- Add unit tests for constants and inline functions

Also add tests for different kinds of Kotlin classes: CLASS,
FILE_FACADE, MULTIFILE_CLASS.

-Add unit test for nested classes

Also remove the existing integration test for nested classes to keep the
integration tests focused on the key scenarios while unit tests will
cover the corner cases.

Ignore inline functions that are private
This commit is contained in:
Hung Nguyen
2021-12-15 19:38:47 +00:00
committed by nataliya.valtman
parent 534cf0c6c8
commit a900f2b66d
153 changed files with 605 additions and 1790 deletions
@@ -652,8 +652,10 @@ private fun getConstantsMap(bytes: ByteArray): LinkedHashMap<String, Any> {
ClassReader(bytes).accept(object : ClassVisitor(Opcodes.API_VERSION) {
override fun visitField(access: Int, name: String, desc: String, signature: String?, value: Any?): FieldVisitor? {
val staticFinal = Opcodes.ACC_STATIC or Opcodes.ACC_FINAL or Opcodes.ACC_PRIVATE
if (value != null && access and staticFinal == Opcodes.ACC_STATIC or Opcodes.ACC_FINAL) {
if (access and Opcodes.ACC_PRIVATE == Opcodes.ACC_PRIVATE) return null
val staticFinal = Opcodes.ACC_STATIC or Opcodes.ACC_FINAL
if (value != null && access and staticFinal == staticFinal) {
result[name] = value
}
return null
@@ -689,7 +691,9 @@ private fun getInlineFunctionsMap(header: KotlinClassHeader, bytes: ByteArray):
desc: String,
signature: String?,
exceptions: Array<out String>?
): MethodVisitor {
): MethodVisitor? {
if (access and Opcodes.ACC_PRIVATE == Opcodes.ACC_PRIVATE) return null
val dummyClassWriter = ClassWriter(0)
dummyClassWriter.visit(dummyVersion, 0, "dummy", null, AsmTypes.OBJECT_TYPE.internalName, null)
@@ -204,6 +204,9 @@ object ConstantExternalizer : DataExternalizer<Any> {
}
}
// The constants' values are provided by ASM, so their types can only be the following.
// See https://asm.ow2.io/javadoc/org/objectweb/asm/ClassVisitor.html#visitField(int,java.lang.String,java.lang.String,java.lang.String,java.lang.Object)
// (Note: Boolean constants have Integer (0, 1) values in ASM.)
private enum class Kind {
INT, FLOAT, LONG, DOUBLE, STRING
}