Java JLS,一个类型的超类型集

Java JLS, the supertype set of a type

JLS 的 section 描述了 ST(U) 是什么,其中 U 是一种类型:

Let ST(Ui) be the set of supertypes of Ui.

在那下面几行,在同一节中,有一个例子:

For example, given List<String> and List<Object>, simply intersecting the sets ST(List<String>) = { List<String>, Collection<String>, Object } and ST(List<Object>) = { List<Object>, Collection<Object>, Object } would yield a set { Object }, and we would have lost track of the fact that the upper bound can safely be assumed to be a List.

ST(List) 不应该也包含 Iterable 吗?

你说得对,ST(List<String>) 应该包含 Iterable<String>。此外,ST(List<String>) 应包含 ListList 的所有超类型,因为 JLS 8 Section 4.10.2

Given a generic type declaration C<F1,...,Fn> (n > 0), the direct supertypes of the parameterized type C<T1,...,Tn>, where Ti (1 ≤ i ≤ n) is a type, are all of the following:

  • ...
  • The raw type C.

所以这个例子实际上并没有展示它想要展示的东西,因为 List 实际上是在 ST(List<String>)ST(List<Object>) 的交叉点,在 EST 出现之前。

我认为该示例可能是为早期版本的超类型化规则编写的,然后在规则更改时没有更新。 Java 7 JLS defines the supertype relationship differently,但即便如此,我认为 Iterable<String> 会是 List<String>.

的超类型