java - JDK 1.7 breaks backward compatibility? (generics) -


i've found similar topics, overly complicated , not quite same. thing is. here's the(minimal) code fine on 1.6, doesn't compile 1.7 javac.

public class test {     private static class a<t>{};     private static class b{};     private static class c{};      b dosomething(a<b> arg){         return new b();     }      c dosomething(a<c> arg){         return new c();     } } 

on 1.7 error this:

java: name clash: dosomething(test.a<test.c>) , dosomething(test.a<test.b>) have same erasure 

i understand type erasure , why it's wrong code. don't understand why can have code in our project compiling , running in 1.6, when 1.7 have problems it. wrong? bug in 1.6 compiler allows so? possible make work in 1.7 other rewriting?

  • jdk1.6 javac version: 1.6.0_43
  • jdk1.7 javac version: 1.7.0_25

you're quite right, under jls3 code should never have compiled , bug in 1.6.

for release of 1.7 of underlying type system updated , bug fixed, result better type handling @ cost of backward compatibility issues.

as getting work in 1.7, believe re-factoring option.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -