Hello, I’ve read somewhere (but I cannot recall wh...
# random
j
Hello, I’ve read somewhere (but I cannot recall where) that there are “cheap” reflection methods and “expensive” reflection methods in Kotlin, do anyone know where may I find more information regarding that?
m
I think you may be referring to the invokedynamic API introduced in Java 7 and used in Java 8 to implement fast execution of lambdas. It’s a JVM feature that lets you invoke methods faster than with standard reflection, could be this you’ve read?
j
Sorry, it wasn’t that… It was something like lite reflection methods (not requiring you to import
reflect
library). Regarding that, do I need to import
reflect
to use something like
Type::field
? Thanks for sharing your thoughts :)
m
Sorry I’ve never heard anything like that. The only “lite” reflection I can think of is
java.lang.invoke
. If you’re referring to Kotlin specifically, from what you tell maybe you’re referring to function references: depending on the usage you don’t need to import the reflect library (although it’s still reflection). Instead, to manipulate stuff like
Type::field
yes, you need to import
kotlin-reflect
.
j
Thanks @Matteo Mirk
👍 1