A question about Reflexion in Kotlin. Are all clas...
# announcements
p
A question about Reflexion in Kotlin. Are all classes in Kotlin static? For some reason I found myself the other day porting the TypeToken of Gson into Kotlin. (I think I almost got it) But when I went to run the test: https://github.com/google/gson/blob/master/gson/src/test/java/com/google/gson/internal/GsonTypesTest.java#L40 If fails to throw an exception because for some reason D::class.java is always static. Are all the types in Kotlin compiled down to static classes? It’s a bit strange, I was expecting to be failing somewhere else. Here is what I’ve done so far, in case someone has better eyes than me 🙂 https://gist.github.com/pablisco/b21070d6df6622f529e639dbabdb2af1
g
Nested classes in Kotlin are static by default. To make it non static add modifier
inner
You can check docs - https://kotlinlang.org/docs/reference/nested-classes.html#inner-classes
p
Sweet, I'll try that for the tests. Cheers
@gildor That worked, amazing. thanks 🍻
🍺 1