Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在检查来自 Kotlin 源的 .class 文件的内容(只是“Hello World”,仅此而已)时,我在常量池中发现了一个 UTF-8 字符串,该字符串 (a) 未在任何地方使用并且 (b) 具有奇怪的内容。
谁能告诉我这是什么?
这是kotlin.Metadata注释的内容。它使用 Protobuf 编码,并由编译器和 Kotlin-Reflect 使用。
kotlin.Metadata
Kotlin 使用String而不是byte[]因为类格式在存储数组时非常浪费。
String
byte[]
当您不使用 Kotlin-Reflect 时,元数据未使用,可以被 ProGuard 删除。