Allow use of 1.5 features when compiling code targeting older JDK versions
Right now, you cannot specify javac flag -source 1.5 without also specifying -target 1.5.
I can understand that some of the JDK1.5 features wouldn't work on older runtimes, but some of the features would work even on the older Java JVMs!
Enhanced for loops, autoboxing, varargs, annotations processing (in source scope) - all these useful features do not require a special new 1.5 JVM. Heck, even the generics will more or less work! And why not simply use StringBuffer instead of StringBuilder for joining strings when targeting old JDK versions? I dont care about reflection not being able to work with generics when running on old JVMs...
If any particular use of 1.5 feature would be impossible to implement on older JVM, error should be issued for that particular use of the feature, not disable the use of all features as a whole!
For example: I have a project that builds several verions of the library for different JDKs: 1.5, 1.4, 1.3, 1.2. I'd like to be able to use the annotations as part of the build process to control into what JARs to include given class, and for which Java versions it is intended (and with what -target option to compile it), cross-compiling from JDK 1.5 to 1.4, 1.3 and 1.2 . All this would be at source level and I don't see why would there be any problem with it compiling with -target 1.4 or less. I'm quite disappointed I can't use -source 1.5 -target 1.4. I cant use the 1.5 target comiled classes because of the classfile format version bump ;(