Is there a posibillity to get a generic type of a field(var/val) declared in a kotlin class ? The following example shows the difference between Java and Kotlin
// Java class
public class ParamTypeJ {
java.util.Collection<Date> col;
}
// Kotlin class
public class ParamTypeK {
var col: java.util.Collection<Date>? = null
}
ParamTypeJ.class.getDeclaredFields()[0].getGenericType() // java.util.Collection<java.util.Date> , instanceof ParameterizedType
ParamTypeK.class.getDeclaredFields()[0].getGenericType() // interface java.util.Collection, instanceof Type
I stumbled on this by trying ormlite with kotlin and getting an exception - produced by:
Type type = field.getGenericType();
if (!(type instanceof ParameterizedType)) {
throw new SQLException("Field class for '" + field.getName() + "' must be a parameterized Collection.");
}
Maybe there is some workaround to this issue?