JDK-6452570 : List.class must be of type Class> and (not) Class
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2006-07-25
  • Updated: 2006-07-25
  • Resolved: 2006-07-25
Related Reports
Duplicate :  
Description
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.

Comments
EVALUATION This is a dupe of 6184881.
25-07-2006