https://kotlinlang.org logo
Title
b

Bernhard

02/02/2019, 8:19 AM
so @JvmField kinda generates metadata twice, once for kotlin and once for java?
p

Pavlo Liapota

02/02/2019, 8:48 AM
What do you mean by
compatible with java
? You can assess Kotlin property from Java.
@JvmField
instructs compiler to define just a field instead of getter, setter and backing field.
b

Bernhard

02/02/2019, 8:49 AM
I see, thank you
my issue is with protected properties
apparently you can't access the field directly without @JvmField annotation, only the getters/setters
I suppose this is because you want get get() and set() to work
p

Pavlo Liapota

02/02/2019, 9:07 AM
Do you want to get java field, i.e.
java.lang.reflect.Field
from java reflection or kotlin reflection? If latter, then this https://kotlinlang.org/docs/reference/reflection.html#interoperability-with-java-reflection may help.
b

Bernhard

02/02/2019, 9:27 AM
no, just plainly accessing the field without getter
but thanks for the reflection link
will do a company internal presentation highlighting java interop so I'm only trying to figure out the reason when to use these annotations
p

Pavlo Liapota

02/02/2019, 9:33 AM
no, just plainly accessing the field without getter
Ah, I see, then yes, you need
@JvmField
to do so.
will do a company internal presentation highlighting java interop
Nice! I guess you saw this presentation

https://www.youtube.com/watch?v=zlggmRMadsU

?
b

Bernhard

02/02/2019, 9:36 AM
thank you!