final Object sourceVersion = this.options.get(CompilerOptions.OPTION_Source);
final Object compliance = this.options.get(CompilerOptions.OPTION_Compliance);
if (sourceVersion.equals(CompilerOptions.VERSION_1_7)
&& CompilerOptions.versionToJdkLevel(compliance) < ClassFileConstants.JDK1_7) {
// compliance must be 1.7 if source is 1.7
throw new InvalidInputException(this.bind("configure.incompatibleComplianceForSource", (String)this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_7)); //$NON-NLS-1$
} else if (sourceVersion.equals(CompilerOptions.VERSION_1_6)
&& CompilerOptions.versionToJdkLevel(compliance) < ClassFileConstants.JDK1_6) {
// compliance must be 1.6 if source is 1.6
throw new InvalidInputException(this.bind("configure.incompatibleComplianceForSource", (String)this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_6)); //$NON-NLS-1$
} else if (sourceVersion.equals(CompilerOptions.VERSION_1_5)
&& CompilerOptions.versionToJdkLevel(compliance) < ClassFileConstants.JDK1_5) {
// compliance must be 1.5 if source is 1.5
throw new InvalidInputException(this.bind("configure.incompatibleComplianceForSource", (String)this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_5)); //$NON-NLS-1$
} else if (sourceVersion.equals(CompilerOptions.VERSION_1_4)
&& CompilerOptions.versionToJdkLevel(compliance) < ClassFileConstants.JDK1_4) {
// compliance must be 1.4 if source is 1.4
throw new InvalidInputException(this.bind("configure.incompatibleComplianceForSource", (String)this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_4)); //$NON-NLS-1$
}
// check and set compliance/source/target compatibilities
if (this.didSpecifyTarget) {
final Object targetVersion = this.options.get(CompilerOptions.OPTION_TargetPlatform);
// tolerate jsr14 target
if (CompilerOptions.VERSION_JSR14.equals(targetVersion)) {
// expecting source >= 1.5
if (CompilerOptions.versionToJdkLevel(sourceVersion) < ClassFileConstants.JDK1_5) {
throw new InvalidInputException(this.bind("configure.incompatibleTargetForGenericSource", (String) targetVersion, (String) sourceVersion)); //$NON-NLS-1$
}
} else {
// target must be 1.7 if source is 1.7
if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_7
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_7){
throw new InvalidInputException(this.bind("configure.incompatibleTargetForSource", (String) targetVersion, CompilerOptions.VERSION_1_7)); //$NON-NLS-1$
}
// target must be 1.6 if source is 1.6
if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_6
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_6){
throw new InvalidInputException(this.bind("configure.incompatibleTargetForSource", (String) targetVersion, CompilerOptions.VERSION_1_6)); //$NON-NLS-1$
}
// target must be 1.5 if source is 1.5
if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_5
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_5){
throw new InvalidInputException(this.bind("configure.incompatibleTargetForSource", (String) targetVersion, CompilerOptions.VERSION_1_5)); //$NON-NLS-1$
}
// target must be 1.4 if source is 1.4
if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_4
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_4){
throw new InvalidInputException(this.bind("configure.incompatibleTargetForSource", (String) targetVersion, CompilerOptions.VERSION_1_4)); //$NON-NLS-1$
}
// target cannot be greater than compliance level
if (CompilerOptions.versionToJdkLevel(compliance) < CompilerOptions.versionToJdkLevel(targetVersion)){
throw new InvalidInputException(this.bind("configure.incompatibleComplianceForTarget", (String)this.options.get(CompilerOptions.OPTION_Compliance), (String) targetVersion)); //$NON-NLS-1$
}
}
}
}