我已将 kotlin-reflect 库添加到我的 Android 项目中,现在 Proguard 正在生成数百行注释,列出所有具有名为 字段的类INSTANCE
,其中当然包括每个 Kotlin object
。
这只是 Proguard 输出的一小部分:
Note: kotlin.reflect.jvm.internal.KClassImpl$Data$objectInstance$2 accesses a declared field 'INSTANCE' dynamically
Maybe this is program field 'co.zsmb.example.proguardkttest.MySingleton { co.zsmb.example.proguardkttest.MySingleton INSTANCE; }'
Maybe this is program field 'kotlin.UNINITIALIZED_VALUE { kotlin.UNINITIALIZED_VALUE INSTANCE; }'
Maybe this is program field 'kotlin.Unit { kotlin.Unit INSTANCE; }'
Maybe this is program field 'kotlin._Assertions { kotlin._Assertions INSTANCE; }'
Maybe this is program field 'kotlin.collections.EmptyIterator { kotlin.collections.EmptyIterator INSTANCE; }'
Maybe this is program field 'kotlin.collections.EmptyList { kotlin.collections.EmptyList INSTANCE; }'
Maybe this is program field 'kotlin.collections.EmptyMap { kotlin.collections.EmptyMap INSTANCE; }'
Maybe this is program field 'kotlin.collections.EmptySet { kotlin.collections.EmptySet INSTANCE; }'
Maybe this is program field 'kotlin.comparisons.NaturalOrderComparator { kotlin.comparisons.NaturalOrderComparator INSTANCE; }'
如您所见,它既包括我自己的MySingleton
类,也包括来自 Kotlin 标准库的许多类,并且它也可以在任何其他库中找到这些字段(如果存在)。