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

List.class must be of type Class<List<?>> and (not) Class<List>

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • specification
    • x86
    • linux

      A DESCRIPTION OF THE REQUEST :
      Class literals should contain be parametrized with a wildcard. There should be an analogy between an array creation and a class literal:

      ArrayList<?> list=new ArrayList<?>[5];

      Class<ArrayList<?>> listClass=ArrayList.class;

      Software developers must go back to raw types when they want to use class literals. This feature must be enabled until generics work without erasure.


      JUSTIFICATION :
      When I want to implement this interface

      public interface Transformator<A,B> {
      Class<? extends A> inputProblem();
      Class<? extends B> outputProblem();
      }

      I can only do it now by

      public class Foo implements Transformator<List,Map>

      and not by

      public class Foo implements Transformator<List<?,Map<?,?>>

      which forces me to use raw types everywhere.

      It doesn't make sence that wildcard arrays are allowed and wildcard class literals not.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Class literals should be only, additionally or castable to a wildcarded type.
      ACTUAL -
      Class literals are of unparametrized types.

      CUSTOMER SUBMITTED WORKAROUND :
      No real workaround exists. Only a drawback: Working with raw types.

            Unassigned Unassigned
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: