{
WildcardType wildcardType = (WildcardType)type;
Type[] bounds = wildcardType.getUpperBounds();
if (bounds.length > 1)
{
throw new DefinitionException("Illegal use of wild card type with more than one upper bound: " + wildcardType);
}
else if (bounds.length == 0)
{
return Object.class;
}
else
{
return getClass(bounds[0]);
}
}
else if (type instanceof TypeVariable)
{
TypeVariable<?> typeVariable = (TypeVariable<?>)type;
if (typeVariable.getBounds().length > 1)
{
throw new DefinitionException("Illegal use of type variable with more than one bound: " + typeVariable);
}
else
{
Type[] bounds = typeVariable.getBounds();
if (bounds.length == 0)
{
return Object.class;
}
else
{
return getClass(bounds[0]);
}
}
}
else
{
throw new DefinitionException("Unsupported type " + type);
}
}