Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8009926

Clarify JLS 4.10.2 subtyping for generic v. parameterized type

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 7
    • specification
    • None
    • Verified

      JLS3 tried to shoehorn non-generic and generic types into the same definitions, and said "parameterized type" in one place where it really really needed to say "generic type". JLS7 was also confused. Let's be crystal clear in JLS8:

      1. Given a non-generic type declaration C, the direct supertypes of the type C are all of the following:

      - The direct superclass of C (8.1.4).
      - The direct superinterfaces of C (8.1.5).
      - The type Object, if C is an interface type with no direct superinterfaces (9.1.3).

      2. Given a generic type declaration C<F1,...,Fn> (n>0), the direct supertypes of the raw type C (4.8) are all of the following:

      - The direct superclass of the raw type C.
      - The direct superinterfaces of the raw type C.
      - The type Object, if C<F1,...,Fn> is a generic interface type with no direct superinterfaces (9.1.2).

      3. Given a generic type declaration C<F1,...,Fn> (n>0), the direct supertypes of the _generic_ type C<F1,...,Fn> are all of the following:

      - The direct superclass of C<F1,...,Fn>.
      - The direct superinterfaces of C<F1,...,Fn>.
      - The type Object, if C<F1,...,Fn> is a generic interface type with no direct superinterfaces.
      - The raw type C (4.8).

      4. 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:

      - D<U1 θ,...,Uk θ>, where D<U1,...,Uk> is a generic type which is a direct supertype of the generic type C<F1,...,Fn> and θ is the substitution [F1:=T1,...,Fn:=Tn].
      - C<S1,...,Sn>, where Si contains Ti (1 ≤ i ≤ n) (4.5.1).
      - The type Object, if C<F1,...,Fn> is a generic interface type with no direct superinterfaces.
      - The raw type C.

            abuckley Alex Buckley
            abuckley Alex Buckley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: