|
Duplicate :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
This source code:
-----------------------------------------------------------------------------
public class GenericTest {
public static interface Interface<T> { }
public static class IntegerInterface implements Interface<Integer> { }
public static <I extends Interface<T>, T> T getGenericValue(I test) {
return null;
}
public static void testSet(Integer test) { }
public static void main(String args[]) {
Integer test = getGenericValue(new IntegerInterface());
testSet(getGenericValue(new IntegerInterface())); //flagged as an error
}
}
---------------------------------------------------------------------------------------
Produces the following compilation error:
---------------------------------------------------------------------------------------
GenericTest.java:15: testSet(java.lang.Integer) in GenericTest cannot be applied to (java.lang.Object)
testSet(getGenericValue(new IntegerInterface())); //flagged as an error
^
1 error
---------------------------------------------------------------------------------------
On:
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b22)
Java HotSpot(TM) Server VM (build 11.0-b08, mixed mode)
But not on:
java version "1.6.0_05-ea"
Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b04)
Java HotSpot(TM) Tiered VM (build 1.6.0_05-ea-b04, mixed mode)
|