The following code compiles using JDK6 (I tried 1.6.0_24)
class XY<A extends XY<A, B>, B extends XY<B, A>> { }
But compiling under JDK7 (e.g. 1.7.0), I get this error:
XY.java:1: error: type argument B is not within bounds of type-variable A
class XY<A extends XY<A, B>, B extends XY<B, A>> {
^
where B,A are type-variables:
B extends XY<B,A> declared in class XY
A extends XY<A,B> declared in class XY
1 error
Can anyone point as to whether this was an intentional change to Java's generics?
It seems that's a bug that comes from OpenJDK and is caused by a bug in type-variable substitution.
It appears when you switch generic variables for examples:
class XY<A extends XY<A, B>, B extends XY<B, A>> { }
class XY<A extends XY<B, A>, B extends XY<A, B>> { }
It doesn't appear in this:
class XY<A extends XY<A, B>, B extends XY<A, B>> { }
class XY<A extends XY<B, A>, B extends XY<B, A>> { }
you can see another example here: http://old.nabble.com/Apparent-generics-compilation-bug-new-to-Java-1.7-td33378164.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With