Hello, I have a sample that works in java but doesn’t works after converting it in Kotlin:
fun main(args: Array<String>) {
val a = A()
a.init()
System.out.println(a.foo) //prints 0, but in java it prints 1
}
class A : B() {
// @Throws(IllegalAccessException::class)
fun init() {
for (field in B::class.java.fields) {
field.setByte(this, 1.toByte())
}
}
}
open class B {
var foo: Byte = 0
private val bar: Byte = 0
}