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

4.10.4: Clarify lub behavior when it encounters a malformed glb

    XMLWordPrintable

Details

    Description

      The lub of two types sometimes produces a lower-bounded wildcard of the form '? super glb(S, T)'. The types S and T can be arbitrary types; in general, glb(S,T) may be undefined (for example, if S and T are unrelated classes). When this occurs, the lub is, in turn, undefined.

      Since the purpose of glb in this context is just to provide some extra typing information, in the case of incompatible types, probably the right way to recover is to use an unbounded wildcard.

      Examples:
      lub(List<? super Runnable>, List<? super Cloneable>) = List<? super Runnable & Cloneable>
      lub(List<? super String>, List<? super Integer>) = List<?> (incompatible glb)

      Attachments

        Activity

          People

            dlsmith Dan Smith
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: