9

With the problably widely known exception of the introduction of the 'assert' keyword, has there ever been a change in the Java language specification which caused old code to be no longer compatible with newer source levels of the JDK?


Summary so far (many thanks for the comments):

"Older" Java code can cause compilation errors, when upgrading to a later version, if the code uses declarations using one of the keywords which where introduced in a later version of the Java language specification (JLS):

  • assert
  • enum
  • strictfp
  • 5
    enum comes to mind as well. – JB Nizet May 12 '13 at 10:30
  • 1
    strictfp. It was default before 1.2 – Piotr Praszmo May 12 '13 at 10:31
  • 2
    @Dima Goltsman, nio did not introduce any language changes. assert and enum are keywords, so their introduction broke old code that used these words as identifiers. For example enums library from Jakarta Commons. – AlexR May 12 '13 at 10:44
  • 1
    Created answer to summarize, can't really think of anything else at the moment (good point for Java). @javadeveloper changing Override behavior didn't break compatibility. – pcalcao May 12 '13 at 11:15
7

Java 1.2

  • strictfp keyword.

Java 1.4

  • assert keyword.

Java 1.5

  • enum keyword.
2

I believe that _ was designated a "keyword" in Java 9. See https://blogs.oracle.com/sundararajan/underscore-is-a-keyword-in-java-9%2c-use-this-script-to-check-your-code

2

Java 10 made var a keyword. It's still a valid variable name but an illegal class name.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.