Is it possible to develop using newer Java (eg 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?
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.