0
votes

Is it possible for Eclipse to tell you when you're using classes that are available in Java releases beyond your project's compliance level (even though the JDK I'm compiling with technically supports/has those classes)?

I'm using a Java 7 JDK for both my Java 6 and Java 7 execution environments in Eclipse (Version: Kepler Release, Build id: 20130614-0229).

I've set the compliance level of my project to Java 6 since we're compiling to Java 6 compatible byte code to support older JREs and I'm using a JavaSE-1.6 Exeuction environment but backed by a Java 1.7.0_15 JDK.

I recently found myself using something in the java.nio.* package and was surprised that I didn't get an error/warning in Eclipse telling me that my compliance level was Java 6 and this class was not available in Java 6.

Of course, I can always switch to a Java 6 JDK, but I'd prefer to use a Java 7 JDK for both execution environments.

Thanks!

1

1 Answers

0
votes

A 7 runtime fulfills the requirements of a 6 Execution Environment. Targeting an actual Java 6 runtime is what you're supposed to do if you want compilation errors using anything that's not in there. Remember, it's not just new classes in 7, it's new methods.