I\'ve a maven project with the maven-compiler-plugin configured as below:
maven-compiler-plugin
Neither target
nor source
relate in any way to what classes are available on the compiler's classpath. If you're compiling your code with the 1.7 compiler then any classes that shipped with 1.7 will be available to your code.
What target
does is tell the compiler to output .class files in a format that is compatible with the 1.6 release of java. source
says only accept java code that would compile with the 1.6 version of the compiler.
So it's perfectly legitimate to make a call to a class that shipped only on 1.7 or later using Java 1.6 compatible source code written into a class file that is compatible with Java 1.6. It just won't run on 1.6.
The only way to ensure your code will run on 1.6 (if that's what you're trying to do) is to use a 1.6 JDK to compile your project.