ReflectionUtils: java.lang.IndexOutOfBoundsException: 0
Closed this issue · 1 comments
wajda commented
java.lang.IndexOutOfBoundsException: 0
at scala.collection.LinearSeqOptimized.apply(LinearSeqOptimized.scala:67)
at scala.collection.LinearSeqOptimized.apply$(LinearSeqOptimized.scala:65)
at scala.collection.immutable.List.apply(List.scala:89)
at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaVanillaMethodMirror1.jinvokeraw(JavaMirrors.scala:407)
at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror.jinvoke(JavaMirrors.scala:373)
at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaVanillaMethodMirror.apply(JavaMirrors.scala:389)
at za.co.absa.commons.reflect.ReflectionUtils$.$anonfun$extractFieldValue$3(ReflectionUtils.scala:139)
at scala.Option.map(Option.scala:230)
at za.co.absa.commons.reflect.ReflectionUtils$.reflectClass$1(ReflectionUtils.scala:137)
at za.co.absa.commons.reflect.ReflectionUtils$.reflectClassHierarchy$1(ReflectionUtils.scala:113)
at za.co.absa.commons.reflect.ReflectionUtils$.extractFieldValue(ReflectionUtils.scala:165)
at za.co.absa.commons.reflect.ReflectionUtils$.extractFieldValue(ReflectionUtils.scala:180)
wajda commented
The exception occurs when a class has a method with a non-empty parameter list with the same name as the field that is being extracted. E.g. :
trait T[A]
object O {
private def x[A: T]: Int = ... // a method with an implicit parameter
private def x: Int = 42
}
ReflectionUtils.extractFieldValue(O, "x") // throws an exception!