Jay
09/12/2021, 5:25 PMval x: String by lazy{...}
When I decompile the Kotlin code into Java code, I see that the getX() method is not ultimately called this method
public inline operator fun <T> Lazy<T>.getValue(thisRef: Any?, property: KProperty<*>): T = value
It is the getter method of value, which is getValue()
instead of getValue(thisRef: Any?, property: KProperty<*>)
So, I don’t understand how the method getValue(thisRef: Any?, property: KProperty<*>)
is called during the execution of lazyJay
09/12/2021, 5:25 PMJay
09/12/2021, 5:31 PMval map2: MutableMap<String, Any?> = mutableMapOf("age" to "Jay", "name" to "18")
var age: Int? by map2
@Nullable
public final Integer getAge() {
Map var1 = this.age$delegate;
KProperty var3 = $$delegatedProperties[1];
boolean var4 = false;
return (Integer)MapsKt.getOrImplicitDefaultNullable(var1, var3.getName());
}
public final void setAge(@Nullable Integer var1) {
Map var2 = this.age$delegate;
KProperty var4 = $$delegatedProperties[1];
boolean var5 = false;
var2.put(var4.getName(), var1);
}
Jay
09/12/2021, 5:33 PMephemient
09/12/2021, 6:19 PMJay
09/13/2021, 1:47 AM