<Kotlin set lazy field through Java reflection> I'...
# stackoverflow
u
Kotlin set lazy field through Java reflection I'm trying to play around with Java reflection in Kotlin, and I have the following field in my Kotlin class: val tree: Tree by lazy { getTree(hashGroup, service) } I'd like to set this field through Java reflection, and so far I got to this point: val tField = transaction::class.java.getDeclaredField("tree\$delegate") tField.isAccessible = true tField.set(transaction, newTree) Obviously this is not going to work, because the tree field has a delegate (tree$delegate) and it wants me to...