What is the order of function returned by val KClass<*>.memberFunctions: Collection<KFunction<*>> , is it the order of declaration?
r
Ryan
06/05/2020, 12:55 AM
I wouldn’t make any assumptions here.
👍 1
Ryan
06/05/2020, 12:55 AM
Probably at the whim of the compiler.
👍 1
g
groostav
06/05/2020, 3:14 AM
I know that at runtime one of the key performance advantages the JVM has over C is that the JVM gets to re-order fields according to a heuristic. And the implemention of
Unsafe
makes implications that this is done eagerly. So my guess is: you get them back in the order that the JVM thought would be fastest --effectively random.