I do not know why Eclipse resolves this or is it just a mistake. 1.7 javac will tell you what
error: strings in switch are not supported in -source 1.6
I also don't know why JComboBox works,
System.out.println(new JComboBox<String>() {}.getClass().getGenericSuperclass()); > javax.swing.JComboBox<java.lang.String>
has general information at run time, which should not be. Allow the use of generics for classes that are not common if the IMO is rejected as incompatible. However, I did not work on the JVM6 code. Perhaps this is even a glitch.
But at least switch not technically a problem. http://www.benf.org/other/cfr/java7switchonstring.html shows that this is just a compiler trick that does not require a new language function, API or bytecode.
A simplified example:
int java7(String string) { switch (string) { case "BB": return 12; case "FRED": return 13; } return 0; }
becomes significant
int java6(String string) { switch (string.hashCode()) { case 2112: if (string.equals("BB")) return 12; break; case 2166379: if (string.equals("FRED")) return 13; break; } return 0; }
This is based on the fact that the result of String#hashCode() is specified and should not be changed. The compiler will save you some time to write code faster that does not have a legal code.
The same applies to the diamond operator: for example. new ArrayList<>() can simply be resolved by the compiler.
The android tools that allow you to use the same compatibility with seven 7 allow you to use it. However, the difference is that they use .class files oriented to Java 7. Android needs to convert the .class files to its internal format anyway, so their .class to .dex compiler can use any input to generate instructions that understood Android runtime.
try-with-resource, for example, will not work, since it requires, among others, the AutoCloseable c interface did not exist in Java 6.
And special features like Lambda expressions also require new types of bytecode.