<@U0ANUS2BA> i saw an answer to a question you pro...
# announcements
s
@udalov i saw an answer to a question you provided on SO and just wanted to get some more information. It's about retaining parameter names on constructors
Was hoping you could shed some light on it for me
if you have a moment 🙂
u
sure, what are you interested in?
s
Thanks for such quick reply 🙂 The question I saw your answer on is here: https://stackoverflow.com/questions/36093019/does-kotlin-compiler-always-retain-parameter-names-in-bytecode it was a while ago
but to boil down the issue I am noticing in IntelliJ that the parameter names are NOT retained
at some point the parameter names are lost on a data class constructor
u
how are you checking that?
s
I'm stepping through the spring-data-mongodb code
and i see params being named arg0.....argXX
if I clean and re-build ... parameter names come back
then at some point (hard to pin-point when exactly) they're gone
u
where do you see that — in the IntelliJ decompiler, in the
javap
bytecode output, in the Kotlin bytecode toolwindow, in Kotlin reflection, in Java reflection, … ?
s
as I am stepping through the java code of spring-data-mongo...the code is looking at the constructor of a data class...I am seeing it while stepping through in IntelliJ
spring-data-mongodb code is in Java ... the class that it's looking at is in Kotlin
u
OK, so the StackOverflow link above is irrelevant here because it’s only related to the parameters that are introspected via Kotlin reflection at runtime (
KParameter.name
)
here you should pass the
-java-parameters
command line argument to Kotlin
s
oh ... I will read the docs on that param ... but does it force preservation of param names?
I was not aware of that option ... will try it and read the docs on it
u
there’s no docs unfortunately yet, only
kotlinc -help
. The
-java-parameters
is basically equivalent to javac’s
-parameters
.
s
alright I will check it out ... thanks so much for your help .... I should be able to apply it in the kotlinOptions { ... }
build.gradle
block as well, right?
u
yes
s
haha I just found it too ...
Generate metadata for Java 1.8 reflection on method parameters
that's good enough docs for me
Just need to know when to look! Thank you for pointing it out for me. OGROMNOE SPASIBO!