-
If I wanna code like above in java, it shou be:
I found the source code which is ignored non-public propery,so I had to make it public. However, for safety, I had to make it final too. just like java version data class.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The reflection code today is entirely based on Kotlin reflections, so no, we could not generate a schema from java code. The generated kotlin compiler code is not something that we control, that. would be from the Kotlin team. You can write your code in Kotlin like that if you want to, that is still valid. If you do so you just miss out on all the short-hand help the compiler is giving. You probably shouldn't need to worry much about what type of code the compiler is generating for you. They Kotlin team has many reasons for why they generate their JVM bytecode in a specific way. You could write the class like this but I still think this would generate a getter in bytecode anyway // Valid Kotlin if you wanted
class Widget {
val id: Int
val value: String
contructor(id: Int, value: String) {
this.id = id
this.value = value
}
} |
Beta Was this translation helpful? Give feedback.
The reflection code today is entirely based on Kotlin reflections, so no, we could not generate a schema from java code.
The generated kotlin compiler code is not something that we control, that. would be from the Kotlin team. You can write your code in Kotlin like that if you want to, that is still valid. If you do so you just miss out on all the short-hand help the compiler is giving. You probably shouldn't need to worry much about what type of code the compiler is generating for you. They Kotlin team has many reasons for why they generate their JVM bytecode in a specific way.
You could write the class like this but I still think this would generate a getter in bytecode anyway
// Valid …