我正在阅读关于子类型和转换的 Java 规范,我知道 S <: T 意味着 S 是 T 的子类型。但是,我不明白 |S| 是什么意思。 <:|T|方法?例如在这种情况下:
One type argument is a type variable or wildcard, with an upper bound (from capture conversion, if necessary) of S; and the other type argument T is not a type variable or wildcard; and neither |S| <: |T| nor |T| <: |S|.
|T| T 引用的类型是什么?它指的是T的类别吗?
最佳答案
符号“|T|”表示类型“T”的类型删除,根据 JLS, Section 4.6 中类型删除的定义.
Type erasure is a mapping from types (possibly including parameterized types and type variables) to types (that are never parameterized types or type variables). We write |T| for the erasure of type T. The erasure mapping is defined as follows:
The erasure of a parameterized type (§4.5) G is |G|.
The erasure of a nested type T.C is |T|.C.
The erasure of an array type T[] is |T|[].
The erasure of a type variable (§4.4) is the erasure of its leftmost bound.
The erasure of every other type is the type itself.
所以,“|S| <: |T|”意味着S的删除是T的删除的子类型。
关于Java SE 规范 |S|象征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32381695/