JDK 7 weirdness !
This is completely unintutive behavior in JDK 7.
I am sure the language theorist's will have some reason why it makes perfect sense, but as a programmer, it is confusing and unintutive.
Consider this simple class :
public class Jdk7Bug {
private final int value;
public Jdk7Bug(int value){
this.value = value;
}
public static <C extends Jdk7Bug> void bug(C instance){
System.out.println(instance.value);
}
public static <C extends Jdk7Bug> void works(C instance){
Jdk7Bug val = instance;
System.out.println(val.value);
}
}
As you guessed it, the method 'bug' will fail with compile error in jdk7 (not in 6).
Generics is complicated enough without introducing weirdnesses like this, sigh ...
I am sure the language theorist's will have some reason why it makes perfect sense, but as a programmer, it is confusing and unintutive.
Consider this simple class :
public class Jdk7Bug {
private final int value;
public Jdk7Bug(int value){
this.value = value;
}
public static <C extends Jdk7Bug> void bug(C instance){
System.out.println(instance.value);
}
public static <C extends Jdk7Bug> void works(C instance){
Jdk7Bug val = instance;
System.out.println(val.value);
}
}
As you guessed it, the method 'bug' will fail with compile error in jdk7 (not in 6).
Generics is complicated enough without introducing weirdnesses like this, sigh ...
1 Comments:
Hi Mridul,
What email address can you be reached at?
Thanks.
Post a Comment
<< Home