-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
6
-
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.
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.
- duplicates
-
JDK-6184881 Object.getClass() typing rule could be improved
-
- Open
-