Are there any specific examples of backward incompatibilities between Java versions?

后端 未结 14 747
孤城傲影
孤城傲影 2020-12-02 12:28

Have there been incompatibilities between Java releases where Java source code/Java class files targeting Java version X won\'t compile/run under version Y (where Y > X) ?

14条回答
  •  难免孤独
    2020-12-02 12:57

    Every release of Swing broke something for us, from 1.3 through 1.6.

    The JDBC issue has already been mentioned, but existing code worked.

    From 1.5 to 1.6 there was a change in the behavior of Socket which broke the Cisco client.

    Of course new reserved keywords were introduced.

    The big one which I think was truely unforgivable on Sun's part was System.getenv(). It worked in 1.0, and then was deprecated and changed to throw an error on all platforms under the rather dubious justification that the Mac didn't have system environment variables. Then the Mac got system environment variables, so in 1.5 it was undeprecated and works. There is no reasonable justification for doing that. Return an empty set on a Mac (Swing has much bigger cross-platform issues if you want to care about that level of cross platform consistency) or even on all platforms.

    I never agreed with them turning off the feature, but to change it to throw an error was just a pure breaking change that if they were going to do, they should have just removed the method entirely.

    But, really from 1.0 to 1.1 they were less concerned about backwards compatability. For example, they dropped "private protected" as a modifier.

    So the upshot is that every version changes enough to require close evaluation, that is why you still see many 1.4 questions here on SO.

提交回复
热议问题