java8 has "-parameters" argument, passed to compiler, what about kotlin ? As I can see, kotlin compiler add @JetValueParameter annotation with param names to parameters, but one is depricated..
Update: Reflection API now supports obtaining parameter names: KCallable.parameters
will give you a list of parameters, and KParameter.name
will give you the name.
The current solution is to use the JetValueParameter
annotation, although it is deprecated.
We're working on support for the parameter names in Kotlin reflection, which will be available shortly. At that point JetValueParameter
will be dropped in favor of the new API.
I'd like to note that Kotlin compiler currently only produces JVM bytecode compatible with Java 1.6, whereas the MethodParameters
attribute corresponding to the -parameters
of javac only appeared in bytecode of Java 1.8. So, you'll still be unable to get parameter names of Kotlin methods via Java reflection. We're considering the support for bytecode target 1.8 though, so that will likely work in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With