Hello. Does anyone (especially Mr. <@U0ANUS2BA>) ...
# library-development
w
Hello. Does anyone (especially Mr. @udalov) know what I should implement to access
org.jetbrains.kotlin.metadata.deserialization
? I am developing a project to rewrite `jackson-module-kotlin` with `kotlinx-metadata-jvm` and I noticed that the initialization process of
KmClass
is slow. It can't simply compare them because the processes are different, but a benchmark on initialization shows that the content under development takes about 1.2 times longer than the original (comparison on
o.w.ser.T_20Props.call
). https://github.com/ProjectMapK/jackson-module-kogera/pull/63 I looked at the profile of this process and found that most of it was the initialization process of
KmClass
. I think this difference is caused by
KmClass
reading all the information at once during initialization. The
KClassImpl
seems to lazily initialize only the information it needs. So I tried to create a
LazyKmClass
that lazily initializes only the necessary information, referring to
kotlinx.metadata.internal.ProtoBuf.Class.accept
. However, I am currently stuck because I can't figure out how to access
org.jetbrains.kotlin.metadata.data.deserialization.protoTypeTableUtil
. Any help would be greatly appreciated.
Oops, I invited Mr. udalov by mistake. My apologies.
u
The
KClassImpl
seems to lazily initialize only the information it needs.
Nope, any non-trivial function or property of
KClass
requires
KClassImpl.data
to be computed which leads to deserialization of all metadata of the class (and sometimes of some other classes)
how to access
org.jetbrains.kotlin.metadata.deserialization.protoTypeTableUtil
org.jetbrains.kotlin
is relocated in kotlinx-metadata-jvm to `kotlinx.metadata.internal`: https://github.com/JetBrains/kotlin/blob/393f880322b0cfd515d05450fccb916eaf88cb00/libraries/kotlinx-metadata/jvm/build.gradle.kts#L59 So you need to import something from package
kotlinx.metadata.internal.metadata.deserialization
to use utilities from that file. Keep in mind that it's internal implementation details, so absolutely no guarantees about it even after kotlinx-metadata-jvm becomes stable
w
Thank you very much. I will take a closer look.