Most of the documentation regarding type erasure handling in Java assumes that the use case is handling a type like SomeType<ParamType>
.
I am trying to process method parameter for the following method:
public void setOtherReferenceRanges(List<ReferenceRange<T>> referenceRanges)
When the container class is instantiated with a type DvQuantity, this signature should become
public void setOtherReferenceRanges(List<ReferenceRange<DvQuanitity>> referenceRanges)
in runtime.
Using reflection one can see that the List
has an actualTypeArgument
which is ReferenceRange<T>
. Since reflection uses class information, I would not expect it to give me ReferenceRange<DvQuantity>
.
However, when I created the class containing this method, I passed the DvQuantity
type as T
. So the type filling in T
should be available to Java runtime, but I could not find a way of getting it. I end up with a TypeVariableImpl
object accessed via reflection, which does not seem to contain any useful data.
Can you think of any ways to discover this information in runtime?