ImmutableSet和java.lang.Iterable的类型镜像isSubtype和isAssignable

ImmutableSet和java.lang.Iterable的类型镜像isSubtype和isAssignable,java,reflection,annotation-processing,Java,Reflection,Annotation Processing,我无法理解subtype和assignable之间的区别 给定参数是ImmutableSet类型,我有以下代码来检查ImmutableSet是子类型还是可分配的: boolean isAssignable = types.isAssignable( types.erasure(parameters.asType()), elements.getTypeElement(Iterable.class.getCan

我无法理解subtype和assignable之间的区别

给定参数是ImmutableSet类型,我有以下代码来检查ImmutableSet是子类型还是可分配的:

      boolean isAssignable =
          types.isAssignable(
              types.erasure(parameters.asType()),
              elements.getTypeElement(Iterable.class.getCanonicalName()).asType());

      boolean isSubtype =
          types.isSubtype(
              types.erasure(parameters.asType()),
              elements.getTypeElement(Iterable.class.getCanonicalName()).asType());

      processingEnv.getMessager().printMessage(Kind.NOTE, "Type " + types.erasure(parameters.asType())
          + " is " + (isSubtype ? "" : " not ") + " a subtype of " + Iterable.class.getCanonicalName());

      processingEnv.getMessager().printMessage(Kind.NOTE, "Type " + types.erasure(parameters.asType())
          + " is " + (isAssignable ? "" : " not ") + " a assignable of " + Iterable.class.getCanonicalName());
输出如下:

Type com.google.common.collect.ImmutableSet is not a subtype of java.lang.Iterable
Type com.google.common.collect.ImmutableSet is a assignable of java.lang.Iterable
我可以理解为什么ImmutableSet可以分配给Iterable接口,这一点非常清楚。然而,我不明白为什么ImmutableSet不是Iterable的一个子类型


我检查了其他类似的问题,但没有一个能解释这一点。有人能帮忙吗?

至少,两种方法在应用
类型时是一致的。擦除(…)
在两个参数上都是一致的。至少,两种方法在应用
类型时是一致的。擦除(…)
在两个参数上都是一致的。