FULL PRODUCT VERSION :
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Valid generics code does not compile under certain conditions
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to compile the code given.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should compile
ACTUAL -
The code does not compile
ERROR MESSAGES/STACK TRACES THAT OCCUR :
tests/CompileTest2.java:26: <R,W>test(java.util.Collection<R>) in tests.CompileTest2.RequestMap<java.lang.Object> cannot be applied to <tests.CompileTest2.DeltaRequest,double[]>(java.util.Collection<tests.CompileTest2.DeltaRequest>)
DeltaRequest o = m.<DeltaRequest, double[]>test (c);
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package tests;
import java.util.Collection;
import java.util.Collections;
public class CompileTest2 {
class Request<R extends Request<R, V>,V> {}
class DeltaRequest extends Request<DeltaRequest, double[]> {}
class RequestMap<V> {
public <R extends Request<R, W>, W extends V> R test (Collection<R> c) {
// In my real code I make use of W of course
return null;
}
}
public void f () {
RequestMap<Object> m = new RequestMap<Object> ();
Collection<DeltaRequest> c = Collections.singleton (new DeltaRequest ());
// This line not compile?
DeltaRequest o = m.<DeltaRequest, double[]>test (c);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Remove the type parameter V from RequestMap