-
Enhancement
-
Resolution: Not an Issue
-
P5
-
None
-
5.0
-
x86
-
linux
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 :
Invalid generics code does compiles under certain conditions
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to compile the code given.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should not compile
ACTUAL -
The code compiles
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package tests;
import java.util.Collection;
import java.util.Collections;
public class CompileTest1 {
class Request<R extends Request<R, V>,V> {}
class RequestMap {
public <R extends Request<R, W>,W> R intersection (Collection<R> c) {
// In my real code I make use of W of course
return null;
}
}
class DeltaRequest extends Request<DeltaRequest,double[]> {}
public void test () {
RequestMap m = new RequestMap ();
Collection<DeltaRequest> c = Collections.singleton (new DeltaRequest ());
// Why does this line compile?
DeltaRequest o = m.intersection (c);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Err ...
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 :
Invalid generics code does compiles under certain conditions
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to compile the code given.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should not compile
ACTUAL -
The code compiles
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package tests;
import java.util.Collection;
import java.util.Collections;
public class CompileTest1 {
class Request<R extends Request<R, V>,V> {}
class RequestMap {
public <R extends Request<R, W>,W> R intersection (Collection<R> c) {
// In my real code I make use of W of course
return null;
}
}
class DeltaRequest extends Request<DeltaRequest,double[]> {}
public void test () {
RequestMap m = new RequestMap ();
Collection<DeltaRequest> c = Collections.singleton (new DeltaRequest ());
// Why does this line compile?
DeltaRequest o = m.intersection (c);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Err ...
- relates to
-
JDK-6559165 inference: Adherence to specification causes inference regression
-
- Closed
-
-
JDK-6369608 inference: Inferred types not substituted in bounds of unconstrained type variables
-
- Closed
-
-
JDK-6811943 inference: javac 1.6 & Eclipse infer more types than JLS (umbrella CR)
-
- Closed
-