-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Endless Loop in EntityContainer #4
Comments
So what I did as a workaround/fix here is: // 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() instanceof Class && EntityContainer.class.isAssignableFrom(((Class)pt.getRawType())) ) {
//if( pt.getRawType() == EntityContainer.class ) {
if (pt.getActualTypeArguments()[0] instanceof Class) {
parameter = (Class)pt.getActualTypeArguments()[0];
break;
}
}
t = ((Class)pt.getRawType()).getGenericSuperclass();
} else if( t instanceof Class ) {
t = ((Class)t).getGenericSuperclass();
} else {
t = null;
}
} So what I changed are two things, the one is the already mentioned iteration just before the else if however that can be removed, since I discovered that further iterating until you are at EntityContainer leaves you with the ActualTypeArgument of This is why the equality check has been changed to Another issue this solution has though is when you have multiple generic parameters like |
Looking at this, I think I understand... but it's going to be very hard for me to test it without a test case. I can create one but not in this round of patches. Leaving this open to look at again after this round of baselining. |
It might be due to my special setup: I have something like
class B extends A<Spatial>
, whereasclass A<T> extends EntityContainer<T>
The code in question is right in the constructor of the EntityContainer:
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 inparameter =
.For some reason, the rawType now is EntityContainer, however the ActualTypeArgument still is
ParameterizedTypeImpl
ofclass A<T>
The text was updated successfully, but these errors were encountered: