[英]Are there any issues when projects have different Java compiler versions?
I have an Eclipse workspace with several Java projects (in Maven); 我有一个带有几个Java项目的Eclipse工作区(在Maven中); these have dependencies on each other.
这些彼此依赖。 Recently I started changing just some of the projects to target Java 1.7, and other than resolving some new warnings, nothing is different when compiling.
最近我开始改变一些项目以Java 1.7为目标,除了解决一些新的警告之外,编译时没有什么不同。
However, it feels like something might go wrong when I try to run everything. 但是,当我尝试运行一切时,感觉会出现问题。 How are class files loaded, and are there any issues, in the following situations?
在以下情况下,如何加载类文件,是否存在任何问题?
When you have java 1.6 project depends on a Java 1.7 project or java 1.7 project depends on a Java 1.6 project, you should always run your program on the higher version of JVM, which is java 1.7 in this case. 当你有java 1.6项目依赖于Java 1.7项目或java 1.7项目依赖于Java 1.6项目时,你应该总是在更高版本的JVM上运行你的程序,在这种情况下是java 1.7。 In a nutshell, in most cases, class files built with the Java SE 6 compiler will run correctly in Java SE 7. But there are some exceptions.
简而言之,在大多数情况下,使用Java SE 6编译器构建的类文件将在Java SE 7中正确运行。但也有一些例外。 Please see Incompatibilities between Java SE 7 and Java SE 6 for a list of incompatibilities between Java 6 and Java 7.
有关Java 6和Java 7之间不兼容的列表,请参阅Java SE 7和Java SE 6之间的不兼容性。
You can build a project with JDK 1.6 that has some libraries that where generated with 1.7 您可以使用JDK 1.6构建一个项目,该项目包含一些使用1.7生成的库
HOWEVER if some of the code from the project 1.7 needs some JDK 1.7 feature (for example, it uses the new Swing combobox with generics) it won't run on a 1.6 JVM. 但是,如果项目1.7中的某些代码需要一些JDK 1.7功能(例如,它使用带有泛型的新Swing组合框),它将无法在1.6 JVM上运行。
So this is something to be very careful about, as you can run into compile time trouble (which is at least not silent) but also runtime trouble. 所以这是非常小心的事情,因为你可能会遇到编译时遇到麻烦(至少不是沉默)但也会遇到运行时问题。 If you can avoid this, it might be better for you.
如果你能避免这种情况,那对你来说可能会更好。
我也面临类似的问题,据我所知,我不认为1.6 VM可以运行任何1.7生成的字节码,但我认为反过来是可能的,因为1.7是1.6VM的升级版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.