I have found that in Eclipse (using the Eclipse compiler) I can use some Java 7 language features but still create Java 6 class files. In the below image, you can see two Java 7 language features that are successfully compiled as a Java 6 class file. However, other Java 7 features, those commented out, do not compile.
My assumption is that Eclipse is determining which Java 7 language features are compatible with the Java 6 JVM and which are not. For example, the generic type JComboBox is just a compilation (and not runtime) feature, so I can imagine how it would be compatible. The switch String feature though I would think might make differences in byte code and rely on new JVM features, but I could be wrong...
My questions:
Is Eclipse really smart enough to know which Java 7 language features are capable of being compiled into Java 6 class files and which are not?
The example below is clearly not 1.6 source compatible, so why does setting "Source compatibility" to 1.6 not cause an error?
This "trick" appears to let me use at least some Java 7 language features and still create Java 6 class files. Using javac with source 1.7 and target 1.6 would fail, so why does this work? Does the Ecilpse compiler have a feature that javac does not?
For the sake of comparison here is the result when I switch to a Java 6 compiler, as expected.