public static Class<?> getRawType(TypeRef<?> typeRef) {
    Type type = typeRef.getType();
    if (type.getClass() == Class.class) {
      return (Class<?>) type;
    } else {
      return getRawType(typeRef.getType());
    }
  }
@Test
  public void testGetRawType() throws NoSuchFieldException {
    assertEquals(
        TypeUtils.getRawType(Test3.class.getDeclaredField("fromField3").getGenericType()),
        ArrayList.class);
    assertEquals(
        TypeUtils.getRawType(Test3.class.getDeclaredField("raw").getGenericType()), List.class);
    assertEquals(
        TypeUtils.getRawType(Test3.class.getDeclaredField("unknown2").getGenericType()), Map.class);
    assertEquals(
        TypeUtils.getRawType(Test3.class.getDeclaredField("arrayUnknown2").getGenericType()),
        Map[].class);
    assertEquals(
        TypeUtils.getRawType(Test3.class.getDeclaredField("unboundWildcard").getGenericType()),
        ArrayList.class);
    assertEquals(
        TypeUtils.getRawType(Test3.class.getDeclaredField("upperBound").getGenericType()),
        ArrayList.class);
  }