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

4.8: Erasure of a type is not always a raw type

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 15
    • Component/s: specification
    • Labels:

      Description

      Since JLS7, 4.8 has stated: [1] (starred text used here for clarity)

      "The type of a constructor (§8.8), instance method (§8.4, §9.4), or non-static field (§8.3) of a raw type C that is not inherited from its superclasses or superinterfaces is ***the raw type that corresponds to*** the erasure of its type in the generic declaration corresponding to C."

      JLS3 4.8 [2] did not have the starred text. It said "... is the erasure of its type in the generic declaration corresponding to C." The starred text was added in JLS7, but is incorrect because the erasure of a type need not be a raw type. For example, suppose the generic class C<T> declares a non-static field `f` of type `int`. In the raw type C, the type of `f` is the erasure of `int`, which is just `int`, which is not a raw type.

      4.8 should say: "The type of a constructor ... of a raw type C that is not inherited ... is the erasure of its type in the generic declaration corresponding to C."

      [1] https://docs.oracle.com/javase/specs/jls/se14/html/jls-4.html#jls-4.8-210
      [2] https://docs.oracle.com/javase/specs/jls/se6/html/typesValues.html#4.8

        Attachments

          Activity

            People

            • Assignee:
              abuckley Alex Buckley
              Reporter:
              gbierman Gavin Bierman
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: