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

compatibility of generic class Class versus ?:

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 5.0
    • tools
    • b28
    • generic
    • solaris_8

      With generic class Class, there is a compatibility problem
      in code such as

          Class c = b ? A.class : B.class;

      This would be illegal (neither Class<A> nor Class<B>
      is a subtype of the other). We propose to resolve this using the same
      algorithm we use for type inference of a call to a method whose signature is

          <T> T f(boolean b, T t1, T t2);

      Using the wildcard notation, the type of the right-hand-side of the
      assignment above is Class<?>, which is compatible with raw Class, so
      the assignment as a whole succeeds.

            gafter Neal Gafter (Inactive)
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: