Search code examples
javajsl

Notation S[F1:=T1,...,Fn:=Tn] in JSL


In section 4.5 of JLS (Parameterized Types) is mentioned the following notation: S[F1:=T1,...,Fn:=Tn].

I do not exactly unbderstand the meaning of this notation.

It is mentioned in the following paragraph:

A generic type has type parameters F1,...,Fn with corresponding bounds B1,...,Bn. Each type argument Ti of a parameterized type ranges over all types that are subtypes of all types listed in the corresponding bound. That is, for each bound type S in Bi, Ti is a subtype of S[F1:=T1,...,Fn:=Tn] (§4.10).

The meaning of the statement above is clear.

But it is not clear for me why we have [F1:=T1,...,Fn:=Tn] after S


Solution

  • It just looks wrong to me.

    First: without the bracketed part, the sentence is a correct restating of the previous statement, and both match my understanding of the java language.

    Second: the notation is wrong. §4.10 references the subtyping and supertyping notation <: and :>, but what is actually used is the replacement notation := (not actually defined as replacement notation in version 8 but was in version 7, and used as replacement in other sections of the document).

    Finally: The previous version of the JSL had an even more nonsensical version of the same notation.

    4.5. Parameterized Types

    A generic class or interface declaration C (§8.1.2, §9.1.2) with one or more type parameters A1,...,An which have corresponding bounds B1,...,Bn defines a set of parameterized types, one for each possible invocation of the type parameter section.

    Each parameterized type in the set is of the form C where each type argument Ti ranges over all types that are subtypes of all types listed in the corresponding bound. That is, for each bound type Si in Bi, Ti is a subtype of Si[F1:=T1,...,Fn:=Tn].

    It has the same brackets, but this time does not even mention what F is prior to being used in the brackets.

    It looks like the brackets were copied incorrectly when this section was rewritten between versions 6 and 7. Version 6 has the brackets but the simply mean the bounds check happens for each type parameter.