https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
m

McEna

11/30/2023, 5:43 PM
Hi folks, is it possible to instance objects using reflection at the common level?
g

Giancarlo Buenaflor

11/30/2023, 5:47 PM
afaik kotlin/native doesn't support creating instance of object with reflection (or ever will?) so probably not
stuck with kotlin jvm I guess
p

Pavel Lahoda

11/30/2023, 8:54 PM
Not possible through reflection, but you can use KSP for that (generate dynamic adapters in KSP and then instantiate your stuff via them). I am doing exactly that in my ObjectForms library, check this talk for more details:

https://www.youtube.com/watch?v=5ZeF24yXigk

g

Giancarlo Buenaflor

11/30/2023, 9:00 PM
Oh cool to know, thx for the info!
m

McEna

12/01/2023, 1:11 AM
Thanks!
2 Views