private static Class findUnderlyingClass(Type t)
    {
        if (t instanceof Class) {
            return (Class) t;
        }
        else if (t instanceof ParameterizedType) {
            ParameterizedType paramType = (ParameterizedType) t;
            return findUnderlyingClass(paramType.getRawType());
        }
        else if (t instanceof WildcardType) {
            WildcardType wt = (WildcardType) t;
            Type[] upperBounds = wt.getUpperBounds();
            // TODO: Handle null and length > 1
            return findUnderlyingClass(upperBounds[0]);
        }
        else if (t instanceof TypeVariable) {
            TypeVariable tv = (TypeVariable) t;
            // TODO: Handle null and length > 1
            return findUnderlyingClass(tv.getBounds()[0]);
        }
        
        return null;
    }