Hi all! I do not how the kotlin compiler works so ...
# compiler
k
Hi all! I do not how the kotlin compiler works so this might be a stupid question. I am curious about how kotlin works older JVMs. My question is Kotlin able to leverage the latest developments in Java like
records
may be helpful in implementing
data
classes.
h
No stupid question! :) One can answer that on different levels of detail. The kotlin compiler outputs jvm bytecode in the end. It can output bytecode for java 6, 8 and so on. In theory, the higher the target, the more new features are supported, just like you say. Currently, jvm default methods are the only thing i know of that needs a higher bytecode level (8) than the Default (6) one. But nothing prevents the compiler from adopting more features of later java Versions. Afaik records don't need and bring any new bytecodes, do they? So this is Not an example where new bytecode would help. Same could be for panama, when No new bytecode is added. I though it's solely based on new jdk implementation, which kotlin should be able to just use without any changes needed, just as one can use new stdlib things from java 9 already.
👍 1
j
Records have new attributes in bytecode which can be read by standard library API to enumerate the names and types of the contained properties
👍 1
k
Thank you for the detailed answer.