Is it possible to develop using newer Java (e.g 9, 10, 11 etc.) versions, and have that Java be compiled down to some older version - such as Java 8?
We would like to use the new features of newer Java versions, but our code needs to run on a Java 8 platform.
If it matters: we are building with Maven.
Phrasing it in Javascript fashion:
Does there exist a Babel Polyfill equivalence for Java?
No - you cannot use new features on an older JVM; the bytecode is incompatible.
You can absolutely use the newer versions of Java to compile down to a lower version, with some caveats around modules.
If you need the new features of newer Java versions, then it's time to migrate to a new version; other than that, where you are will be fine until you require support from Oracle.
Not necessarily. If you have code that uses packages/syntactical structures not defined in previous versions, the program will fail to run/compile.
Think of it this way. Before Java 8, there were not lambda expressions. So if you create a lambda expression in Java 8+ and then attempt to compile it in java 7, the compiler will be like: What is a lambda expression?
In short no. However, you can go the other way. Compile code written in a lower version using a higher version... for the most part.
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