Open
Description
It might be due to my special setup: I have something like class B extends A<Spatial>
, whereas class A<T> extends EntityContainer<T>
The code in question is right in the constructor of the EntityContainer:
// Find out what the type parameter is
for( Type t = getClass().getGenericSuperclass(); t != null; ) {
if( t instanceof ParameterizedType ) {
ParameterizedType pt = (ParameterizedType)t;
if( pt.getRawType() == EntityContainer.class ) {
parameter = (Class)pt.getActualTypeArguments()[0];
break;
}
} else if( t instanceof Class ) {
t = ((Class)t).getGenericSuperclass();
} else {
t = null;
}
}
In my case t is instanceof ParameterizedType
, but the RawType isn't EntityContainer.
I could get around this by adding t = ((Class)pt.getRawType()).getGenericSuperclass();
just before the first else-if, however that leads to a Cast Exception in parameter =
.
For some reason, the rawType now is EntityContainer, however the ActualTypeArgument still is ParameterizedTypeImpl
of class A<T>
Metadata
Metadata
Assignees
Labels
No labels