filtering KOTLIN.LATEINIT
Evgeny Mandrikov edited this page Oct 4, 2017
·
3 revisions
Kotlin supports lateinit properties which are particularly useful in situations, when constructor dependency injection is not available (e.g. using frameworks which support only field/method injection or on Android).
Access to a lateinit property is done this way:
L1
LINENUMBER 67 L1
ALOAD 0
GETFIELD com/better/alarm/background/VibrationService.wakeLock : Landroid/os/PowerManager$WakeLock;
DUP
IFNONNULL L2
LDC "wakeLock"
INVOKESTATIC kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException (Ljava/lang/String;)V
L2
INVOKEVIRTUAL android/os/PowerManager$WakeLock.acquire ()V
As you can see, under normal circumstances this part here will be always missed:
LDC "wakeLock"
INVOKESTATIC kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException (Ljava/lang/String;)V
In other words, IFNONNULL L2
else case always misses.
Perhaps it would be possible to exclude this assuming that no one uses throwUninitializedPropertyAccessException in their code.