javac from JDK N to cross-compiler to an older platform version, the correct practice is to:
bootclasspathto compile against the
rt.jar(or equivalent) for the older platform.
If the second step is not taken,
javac will dutifully use the old language rules combined with new libraries, which can result in class files that do not work on the older platform since references to non-existent methods can get included.
Thanks to work by Jon Gibbons, in JDK 7 build 121 and later
javac detects and warns about this suspicious situation; for example:
$ javac -source 6 HelloWorld.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
One way to address the warning is to set the
bootclasspath. If that is inappropriate, the warning can be disabled with a new suboption within the
With this change, a likely problematic combination of options to
javac that can lead to subtle build errors are diagnosed by the compiler and can easily by either directly addressed, or documented as part of the build process via the new