I've added the kotlin-reflect library to my Android project, and now Proguard is generating hundreds of lines of notes, listing all classes that have a field named INSTANCE
, which of course includes every single Kotlin object
.
Here's just a short part of the Proguard output:
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; }'
As you can see, it includes both my own MySingleton
class, as well as many classes from the Kotlin standard library, and it finds these fields in any other libraries too, if they're present.