I am trying to understand if the compiled kotlin is a java bytecode file. In this example, I show the kt files and the class files, and there certain keywords that I don't know that existed in java. Eg, open val.
Are the compiled kt files formed by bytecodes? Are the compiled kt files executed directly by the JVM?
Greeting.kt
package org.jetbrains.kotlin.demo
data class Greeting(val id: Long, val content: String)
GrettingController.kt
@RestController
class GreetingController {
val counter = AtomicLong()
@GetMapping("/greeting")
fun greeting(@RequestParam(value = "name", defaultValue = "World") name: String) =
Greeting(counter.incrementAndGet(), "Hello, $name")
}
Greeting.class
public final data class Greeting public constructor(id: kotlin.Long, content: kotlin.String) {
public final val content: kotlin.String /* compiled code */
public final val id: kotlin.Long /* compiled code */
public final operator fun component1(): kotlin.Long { /* compiled code */ }
public final operator fun component2(): kotlin.String { /* compiled code */ }
}
GreetingController.class
@org.springframework.web.bind.annotation.RestController public open class GreetingController public constructor() {
public open val counter: java.util.concurrent.atomic.AtomicLong /* compiled code */
@org.springframework.web.bind.annotation.GetMapping public open fun greeting(@org.springframework.web.bind.annotation.RequestParam name: kotlin.String): org.jetbrains.kotlin.demo.Greeting { /* compiled code */ }
}