code: private static void getTypePackageNames(Type type, Map<String, Class<?>> packageNames) {
      if (type instanceof Class<?>) {
        getClassPackageNames((Class<?>) type, packageNames);
      } else if (type instanceof GenericArrayType) {
        getTypePackageNames(((GenericArrayType) type).getGenericComponentType(), packageNames);
      } else if (type instanceof ParameterizedType) {
        getParameterizedTypePackageNames((ParameterizedType) type, packageNames);
      } else if (type instanceof TypeVariable) {
        getTypeVariablePackageNames((TypeVariable) type, packageNames);
      } else if (type instanceof WildcardType) {
        getWildcardTypePackageNames((WildcardType) type, packageNames);
      }
    }
docs: Visits all the components of a type, collecting a map taking the name of
  each package in which package-private types are defined to one of the
  classes contained in {@code type} that belongs to that package.  If any
  private types are encountered, an {@link IllegalArgumentException} is
  thrown.
  
  This is required to deal with situations like Generic<Private> where
  Generic is publically defined in package A and Private is private to
  package B; we need to place code that uses this type in package B, even
  though the top-level class is from A.