I’m running into a weird situation where the prope...
# announcements
d
I’m running into a weird situation where the properties of my companion object are static rather than being part of the companion itself. They do not have a
@JvmStatic
annotation. Anyone have any idea what’s going on? All of the documentation I can find seems to indicate that only the companion object itself should have static. This is causing problems the framework I’m using is trying to use reflection against the local properties and because they are static it’s not working. (This is on 1.3.0 in case it matters)
d
const val
properties become
static
, too.
d
That’s good to know, but I’m using `var`s in this case.
Copy code
class Foo {
    companion object {
        var temp = 3
        var bar = "asdf"

        init {
            val fields = Foo.Companion.javaClass.fields
            fields.forEach {
                println(it.name)
            }
        }
    }
}
This is the test code I’m using to try and isolate the issue.
d
Huh, curious, I did not know that. It seems that the fields are placed in the class always, only getter and setter go into the companion.