What is the difference between using JDK 7 and JDK 8 with 1.7 compiler compliance level?

I was wondering if there is any difference in the work / creation of software under JDK 8 and using the compiler compliance level 1.7 against JDK 7 as the system default. I'm more interested in the link to Android building, building apps, Eclipse, Android Studio, etc.

+5
source share
3 answers

Yes, there are tons of new classes in JDK 1.8, for example, java.time classes. You will not get them if you build JDK 1.7; but you can use them if you build JDK 1.8 with a compiler compliance level of 1.7.

+3
source

Yes, there is a difference between starting / creating software under JDK 8 and using the compiler compliance level 1.7 vs JDK 7 as the system default.

  • running software under JDK 8 and using the compiler matching level: you compile in jdk 1.7 but run on 1.8. No problem, your program will work as needed.

  • JDK 7 as the system default: you compile version 1.7 and run it in the same version.

I wonder in which case would you like to use the first case?

+1
source

truck difference actually. With JDKs, the conformance level is a compiler directive to specifically use the optimization and linking features for the version you specify. He has a lot more under the hood, but I don’t think you want to know. Newer versions of the JDK bring new features, and compilers in this version can understand and link these functions when creating class files or compiled code for your Java source files. Therefore, the JVM runtime in these JDKS is also equipped to handle such optimizations and cases and their processing. Thus, without conformance levels, the class file that you create using JDK8 will only work correctly with battery life based on JDK8. They may not do this with JDK7 or 6. To counter this problem and thus allow your compiled JDK8 code to run on JDK8,7 and possibly even 6, hyou need to appropriately add a compiler directive conformance level. The downside is that you won’t be able to use some of the latest features that the compiler offers, but there aren’t many such cases, and they outweigh the need for interoperability and availability.

+1
source

Source: https://habr.com/ru/post/1208274/


All Articles