I have the following object:
package com.rock
object Asteriod {
val orbitDiam = 334322.3
val radius = 3132.3
val length = 323332.3
val elliptical = false
}
How can I use Java reflection to get the values of each of these variables? I can get the method from the object, I can’t figure out how to get the fields. Is it possible?
Class<?> clazz = Class.forName("com.rock.Asteriod$");
Field field = clazz.getField("MODULE$");
// not sure what to do to get each of the variables?????
Thank!
source
share