Hi All. I'm in the process of migrating a service, written in a combination of Java 8 and Kotlin, to Java 16. I am seeing some bizarre behaviour that I can't find an explanation for. The code below ends up with notTheSame set to true, when someField has the value of 2, which is the same as the value of the constant it is being compared with. (someField is read from a database).
The (obviously modified) code shows the comparison:
fun isXXX(current: Foo, previous: Foo?): Boolean {
val notTheSame = previous?.someField != someConstant
if (notTheSame) {
println("${previous?.someField} != $someConstant")
}
...
}
The data class:
data class Foo(
...
var someField: Short = initial,
...
)
The constants:
const val initial: Short = -1
const val someConstant: Short = 2
Could someone please help me understand the cause, or point me to where I should look? Code hasn't been touched for over a year, and I'm updating every single JAR used at the same time.
Thanks.