Kotlin JS full reflection API


#1

Will Kotlin JS target get full reflection API support anytime soon?

I’m planning to write a tool that would currently use standalone Kotlin compiler (JVM) to create a program generating serialization code for JS target.

If JS target would support full reflection API it would render such (hacky) approach obsolete as I would be able to create object mapper directly in JS target code (well it wouldn’t generate code statically like in approach above, but performance isn’t an issue).

So is full reflection API support planned to be implemented in the near future (in few following months)?


#2

We are going to support full reflection in Kotlin/JS in the future but now we don’t have any ETA about it, so it will not be implemented in near future.

Regarding the serialization issue – we already work on the solution for both JVM and JS. You can find more information in this post and checkout and play with current implementation from here.


#3

Great to hear full reflection is coming to JS, please consider for a poll on desired features next time one is held.


#4

Waiting for this one.


#5

Kotlin JS does not seem to be getting much love… has there been any progress on this?


#6

In one case I found, current Kotlin JS reflection has a different behavior from JVM.

Look here: https://stackoverflow.com/questions/51418597/different-behavior-of-kclass-between-kotlin-jvm-and-kotlin-js


#7

Hello, pls try our kotlin2js reflection plugin, we need a feedback


#8

We have now returned to our project and will try the use of your plugin… however there is no example for use with kotlin gradle script, only with groovy.
Not sure what to do with the

kotlin2JsReflection {
    generatedSourcesDir = file("${project.buildDir}/generated/decembrist")
}

block…as this will not run the same way in kotlin-dsl. The other additions to gradle seem feasible so far, but we are working multi-platform, as the use is within a multiplatform library that uses the reflection. It seems the JSReflection plugin specifically uses the js-kotlin plugin, and cannot work with multiplatform.