简体   繁体   English

Java SE规范| S | 符号

[英]Java SE specifications |S| symbol

I'm reading the Java Specification for subtyping and casting I know S <: T means S is a subtype of T. However, I don't understand what does |S| 我正在阅读有关子类型和类型转换的Java规范,我知道S <:T表示S是T的子类型。但是,我不知道| S |是什么。 <: |T| <:| T | means? 手段? For example in this context: 例如,在这种情况下:

One type argument is a type variable or wildcard, with an upper bound (from capture conversion, if necessary) of S; 一个类型实参是类型变量或通配符,其上限(如果需要,根据捕获转换)为S; and the other type argument T is not a type variable or wildcard; 另一个类型参数T不是类型变量或通配符; and neither |S| 而且| S |都不 <: |T| <:| T | nor |T| 也不| T | <: |S|. <:| S |。

|T| | T | is the type of T reference? 参考的类型是什么? Does it refer to the class of T? 它是否指的是T类?

The notation "|T|" 表示法“ | T |” means the type erasure of type "T", according to the definition of type erasure in the JLS, Section 4.6 . 根据JLS第4.6节中对类型擦除的定义,表示类型“ T”的类型擦除。

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| 我们写| T | for the erasure of type T. The erasure mapping is defined as follows: 用于擦除类型T。擦除映射定义如下:

  • The erasure of a parameterized type (§4.5) G is |G|. 参数化类型(第4.5节)G的擦除为| G |。

  • The erasure of a nested type TC is |T|.C. 嵌套类型TC的擦除为| T | .C。

  • The erasure of an array type T[] is |T|[]. 数组类型T []的擦除为| T | []。

  • The erasure of a type variable (§4.4) is the erasure of its leftmost bound. 擦除类型变量(第4.4节)是擦除其最左边界。

  • The erasure of every other type is the type itself. 其他所有类型的擦除都是该类型本身。

So, "|S| <: |T|" 因此,“ | S | <:| T |” means that the erasure of S is a subtype of the erasure of T. 表示擦除S是擦除T的子类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM