parameters = new HashMap<>();
- parameters.put(Logger.MESSAGE, this.main.bind("configure.requiresJDK1.2orAbove")); //$NON-NLS-1$
- printTag(Logger.ERROR, parameters, true, true);
- }
- this.printlnErr(this.main.bind("configure.requiresJDK1.2orAbove")); //$NON-NLS-1$
- }
-
private void logXmlExtraProblem(CategorizedProblem problem, int globalErrorCount, int localErrorCount) {
final int sourceStart = problem.getSourceStart();
final int sourceEnd = problem.getSourceEnd();
@@ -1692,52 +1680,7 @@ public String bind(String id, String[] arguments) {
}
return MessageFormat.format(message, (Object[]) arguments);
}
-/**
- * Return true if and only if the running VM supports the given minimal version.
- *
- * This only checks the major version, since the minor version is always 0 (at least for the useful cases).
- * The given minimalSupportedVersion is one of the constants:
- *
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_1
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_2
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_3
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_4
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_5
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_6
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_7
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_8
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK9
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK10
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK11
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK12
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK13
- * org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK14
- *
- *
- * @param minimalSupportedVersion the given minimal version
- * @return true if and only if the running VM supports the given minimal version, false otherwise
- */
-private boolean checkVMVersion(long minimalSupportedVersion) {
- // the format of this property is supposed to be xx.x where x are digits.
- String classFileVersion = System.getProperty("java.class.version"); //$NON-NLS-1$
- if (classFileVersion == null) {
- // by default we don't support a class file version we cannot recognize
- return false;
- }
- int index = classFileVersion.indexOf('.');
- if (index == -1) {
- // by default we don't support a class file version we cannot recognize
- return false;
- }
- int majorVersion;
- try {
- majorVersion = Integer.parseInt(classFileVersion.substring(0, index));
- } catch (NumberFormatException e) {
- // by default we don't support a class file version we cannot recognize
- return false;
- }
- return ClassFileConstants.getComplianceLevelForJavaVersion(majorVersion) >=minimalSupportedVersion;
-}
+
/*
* Low-level API performing the actual compilation
*/
@@ -2286,10 +2229,8 @@ public void configure(String[] argv) {
continue;
}
if (currentArg.equals("-inlineJSR")) { //$NON-NLS-1$
+ // ignore, it is enabled by default from 1.5 on
mode = DEFAULT;
- this.options.put(
- CompilerOptions.OPTION_InlineJsr,
- CompilerOptions.ENABLED);
continue;
}
if (currentArg.equals("-parameters")) { //$NON-NLS-1$
@@ -2622,22 +2563,11 @@ public void configure(String[] argv) {
this.bind("configure.unsupportedWithRelease", "-target"));//$NON-NLS-1$ //$NON-NLS-2$
}
this.didSpecifyTarget = true;
- if (currentArg.equals("1.1")) { //$NON-NLS-1$
- this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1);
- } else if (currentArg.equals("1.2")) { //$NON-NLS-1$
- this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_2);
- } else if (currentArg.equals("jsr14")) { //$NON-NLS-1$
- this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_JSR14);
- } else if (currentArg.equals("cldc1.1")) { //$NON-NLS-1$
- this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_CLDC1_1);
- this.options.put(CompilerOptions.OPTION_InlineJsr, CompilerOptions.ENABLED);
+ String targetVersion = optionStringToVersion(currentArg);
+ if (targetVersion != null) {
+ this.options.put(CompilerOptions.OPTION_TargetPlatform, targetVersion);
} else {
- String version = optionStringToVersion(currentArg);
- if (version != null) {
- this.options.put(CompilerOptions.OPTION_TargetPlatform, version);
- } else {
- throw new IllegalArgumentException(this.bind("configure.targetJDK", currentArg)); //$NON-NLS-1$
- }
+ throw new IllegalArgumentException(this.bind("configure.targetJDK", currentArg)); //$NON-NLS-1$
}
mode = DEFAULT;
continue;
@@ -3102,23 +3032,10 @@ public void configure(String[] argv) {
this.pendingErrors = null;
}
}
-/** Translates any supported standard version starting at 1.3 up-to latest into the corresponding constant from CompilerOptions */
+/** Translates any supported standard version starting at {@link CompilerOptions#getFirstSupportedJavaVersion()}
+ * up-to latest into the corresponding constant from CompilerOptions */
private String optionStringToVersion(String currentArg) {
switch (currentArg) {
- case "1.3": return CompilerOptions.VERSION_1_3; //$NON-NLS-1$
- case "1.4": return CompilerOptions.VERSION_1_4; //$NON-NLS-1$
- case "1.5": //$NON-NLS-1$
- case "5": //$NON-NLS-1$
- case "5.0": //$NON-NLS-1$
- return CompilerOptions.VERSION_1_5;
- case "1.6": //$NON-NLS-1$
- case "6": //$NON-NLS-1$
- case "6.0": //$NON-NLS-1$
- return CompilerOptions.VERSION_1_6;
- case "1.7": //$NON-NLS-1$
- case "7": //$NON-NLS-1$
- case "7.0": //$NON-NLS-1$
- return CompilerOptions.VERSION_1_7;
case "1.8": //$NON-NLS-1$
case "8": //$NON-NLS-1$
case "8.0": //$NON-NLS-1$
@@ -4777,20 +4694,12 @@ public void performCompilation() {
String setting = System.getProperty("jdt.compiler.useSingleThread"); //$NON-NLS-1$
this.batchCompiler.useSingleThread = setting != null && setting.equals("true"); //$NON-NLS-1$
- if (this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_6
- && this.compilerOptions.processAnnotations) {
- if (checkVMVersion(ClassFileConstants.JDK1_6)) {
- initializeAnnotationProcessorManager();
- if (this.classNames != null) {
- this.batchCompiler.setBinaryTypes(processClassNames(this.batchCompiler.lookupEnvironment));
- }
- } else {
- // report a warning
- this.logger.logIncorrectVMVersionForAnnotationProcessing();
- }
- if (checkVMVersion(ClassFileConstants.JDK9)) {
- initRootModules(this.batchCompiler.lookupEnvironment, environment);
+ if (this.compilerOptions.processAnnotations) {
+ initializeAnnotationProcessorManager();
+ if (this.classNames != null) {
+ this.batchCompiler.setBinaryTypes(processClassNames(this.batchCompiler.lookupEnvironment));
}
+ initRootModules(this.batchCompiler.lookupEnvironment, environment);
}
// set the non-externally configurable options.
@@ -5377,76 +5286,15 @@ protected void validateOptions(boolean didSpecifyCompliance) {
throw new IllegalArgumentException(
this.bind("configure.unsupportedWithRelease", version));//$NON-NLS-1$
}
- if (CompilerOptions.VERSION_1_3.equals(version)) {
- if (!this.didSpecifySource) this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1);
- } else if (CompilerOptions.VERSION_1_4.equals(version)) {
- if (this.didSpecifySource) {
- Object source = this.options.get(CompilerOptions.OPTION_Source);
- if (CompilerOptions.VERSION_1_3.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_2);
- } else if (CompilerOptions.VERSION_1_4.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- }
- } else {
- this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_2);
- }
- } else if (CompilerOptions.VERSION_1_5.equals(version)) {
- if (this.didSpecifySource) {
- Object source = this.options.get(CompilerOptions.OPTION_Source);
- if (CompilerOptions.VERSION_1_3.equals(source)
- || CompilerOptions.VERSION_1_4.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- } else if (CompilerOptions.VERSION_1_5.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
- }
- } else {
- this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
- }
- } else if (CompilerOptions.VERSION_1_6.equals(version)) {
- if (this.didSpecifySource) {
- Object source = this.options.get(CompilerOptions.OPTION_Source);
- if (CompilerOptions.VERSION_1_3.equals(source)
- || CompilerOptions.VERSION_1_4.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- } else if (CompilerOptions.VERSION_1_5.equals(source)
- || CompilerOptions.VERSION_1_6.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
- }
- } else {
- this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
- }
- } else if (CompilerOptions.VERSION_1_7.equals(version)) {
- if (this.didSpecifySource) {
- Object source = this.options.get(CompilerOptions.OPTION_Source);
- if (CompilerOptions.VERSION_1_3.equals(source)
- || CompilerOptions.VERSION_1_4.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- } else if (CompilerOptions.VERSION_1_5.equals(source)
- || CompilerOptions.VERSION_1_6.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
- } else if (CompilerOptions.VERSION_1_7.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
- }
- } else {
- this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7);
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
- }
- } else if (CompilerOptions.VERSION_1_8.equals(version)) {
+ if(CompilerOptions.UNSUPPORTED_VERSIONS.contains(version)) {
+ throw new IllegalArgumentException(this.bind("configure.unsupportedComplianceVersion", //$NON-NLS-1$
+ this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.getFirstSupportedJavaVersion()));
+ }
+
+ if (CompilerOptions.VERSION_1_8.equals(version)) {
if (this.didSpecifySource) {
Object source = this.options.get(CompilerOptions.OPTION_Source);
- if (CompilerOptions.VERSION_1_3.equals(source)
- || CompilerOptions.VERSION_1_4.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- } else if (CompilerOptions.VERSION_1_5.equals(source)
- || CompilerOptions.VERSION_1_6.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
- } else if (CompilerOptions.VERSION_1_7.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
- } else if (CompilerOptions.VERSION_1_8.equals(source)) {
+ if (CompilerOptions.VERSION_1_8.equals(source)) {
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
}
} else {
@@ -5456,15 +5304,7 @@ protected void validateOptions(boolean didSpecifyCompliance) {
} else if (CompilerOptions.VERSION_9.equals(version)) {
if (this.didSpecifySource) {
Object source = this.options.get(CompilerOptions.OPTION_Source);
- if (CompilerOptions.VERSION_1_3.equals(source)
- || CompilerOptions.VERSION_1_4.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- } else if (CompilerOptions.VERSION_1_5.equals(source)
- || CompilerOptions.VERSION_1_6.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
- } else if (CompilerOptions.VERSION_1_7.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
- } else if (CompilerOptions.VERSION_1_8.equals(source)) {
+ if (CompilerOptions.VERSION_1_8.equals(source)) {
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
} else if (CompilerOptions.VERSION_9.equals(source)) {
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_9);
@@ -5476,15 +5316,7 @@ protected void validateOptions(boolean didSpecifyCompliance) {
} else if (CompilerOptions.VERSION_10.equals(version)) {
if (this.didSpecifySource) {
Object source = this.options.get(CompilerOptions.OPTION_Source);
- if (CompilerOptions.VERSION_1_3.equals(source)
- || CompilerOptions.VERSION_1_4.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- } else if (CompilerOptions.VERSION_1_5.equals(source)
- || CompilerOptions.VERSION_1_6.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
- } else if (CompilerOptions.VERSION_1_7.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
- } else if (CompilerOptions.VERSION_1_8.equals(source)) {
+ if (CompilerOptions.VERSION_1_8.equals(source)) {
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
} else if (CompilerOptions.VERSION_9.equals(source)) {
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_9);
@@ -5499,16 +5331,10 @@ protected void validateOptions(boolean didSpecifyCompliance) {
if (!this.didSpecifyTarget) {
if (this.didSpecifySource) {
String source = this.options.get(CompilerOptions.OPTION_Source);
- if (CompilerOptions.VERSION_1_3.equals(source)
- || CompilerOptions.VERSION_1_4.equals(source)) {
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- } else if (CompilerOptions.VERSION_1_5.equals(source)
- || CompilerOptions.VERSION_1_6.equals(source)) {
- this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
- } else {
- // 1.3 is the lowest version that can be specified as -source
+ {
+ // 1.8 is the lowest version that can be specified as -source
// The following check will ensure '0' is ignored.
- if (CompilerOptions.versionToJdkLevel(source) >= ClassFileConstants.JDK1_7)
+ if (CompilerOptions.versionToJdkLevel(source) >= ClassFileConstants.JDK1_8)
this.options.put(CompilerOptions.OPTION_TargetPlatform, source);
}
} else {
@@ -5522,20 +5348,12 @@ protected void validateOptions(boolean didSpecifyCompliance) {
} else if (this.didSpecifySource) {
String version = this.options.get(CompilerOptions.OPTION_Source);
- // default is source 1.3 target 1.2 and compliance 1.4
- if (CompilerOptions.VERSION_1_4.equals(version)) {
- if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- } else if (CompilerOptions.VERSION_1_5.equals(version)) {
- if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
- } else if (CompilerOptions.VERSION_1_6.equals(version)) {
- if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
- } else if (CompilerOptions.VERSION_1_7.equals(version)) {
- if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7);
- if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
- } else if (CompilerOptions.VERSION_1_8.equals(version)) {
+ if(CompilerOptions.UNSUPPORTED_VERSIONS.contains(version)) {
+ throw new IllegalArgumentException(this.bind("configure.unsupportedSourceVersion", //$NON-NLS-1$
+ this.options.get(CompilerOptions.OPTION_Source), CompilerOptions.getFirstSupportedJavaVersion()));
+ }
+ // default is source 1.8 target 1.8 and compliance 1.8
+ if (CompilerOptions.VERSION_1_8.equals(version)) {
if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8);
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
} else if (CompilerOptions.VERSION_9.equals(version)) {
@@ -5569,22 +5387,6 @@ protected void validateOptions(boolean didSpecifyCompliance) {
&& this.complianceLevel < ClassFileConstants.JDK1_8) {
// compliance must be 1.8 if source is 1.8
throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_8)); //$NON-NLS-1$
- } else if (sourceVersion.equals(CompilerOptions.VERSION_1_7)
- && this.complianceLevel < ClassFileConstants.JDK1_7) {
- // compliance must be 1.7 if source is 1.7
- throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_7)); //$NON-NLS-1$
- } else if (sourceVersion.equals(CompilerOptions.VERSION_1_6)
- && this.complianceLevel < ClassFileConstants.JDK1_6) {
- // compliance must be 1.6 if source is 1.6
- throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_6)); //$NON-NLS-1$
- } else if (sourceVersion.equals(CompilerOptions.VERSION_1_5)
- && this.complianceLevel < ClassFileConstants.JDK1_5) {
- // compliance must be 1.5 if source is 1.5
- throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_5)); //$NON-NLS-1$
- } else if (sourceVersion.equals(CompilerOptions.VERSION_1_4)
- && this.complianceLevel < ClassFileConstants.JDK1_4) {
- // compliance must be 1.4 if source is 1.4
- throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_4)); //$NON-NLS-1$
} else {
long ver = CompilerOptions.versionToJdkLevel(sourceVersion);
if(this.complianceLevel < ver)
@@ -5597,45 +5399,15 @@ protected void validateOptions(boolean didSpecifyCompliance) {
// check and set compliance/source/target compatibilities
if (this.didSpecifyTarget) {
final String 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 IllegalArgumentException(this.bind("configure.incompatibleTargetForGenericSource", targetVersion, sourceVersion)); //$NON-NLS-1$
- }
- } else if (CompilerOptions.VERSION_CLDC1_1.equals(targetVersion)) {
- if (this.didSpecifySource && CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_4) {
- throw new IllegalArgumentException(this.bind("configure.incompatibleSourceForCldcTarget", targetVersion, sourceVersion)); //$NON-NLS-1$
- }
- if (this.complianceLevel >= ClassFileConstants.JDK1_5) {
- throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForCldcTarget", targetVersion, sourceVersion)); //$NON-NLS-1$
- }
+ if(CompilerOptions.UNSUPPORTED_VERSIONS.contains(targetVersion)) {
+ throw new IllegalArgumentException(this.bind("configure.unsupportedTargetVersion", //$NON-NLS-1$
+ this.options.get(CompilerOptions.OPTION_TargetPlatform), CompilerOptions.getFirstSupportedJavaVersion()));
} else {
// target must be 1.8 if source is 1.8
if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_8
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_8){
throw new IllegalArgumentException(this.bind("configure.incompatibleTargetForSource", targetVersion, CompilerOptions.VERSION_1_8)); //$NON-NLS-1$
}
- // 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 IllegalArgumentException(this.bind("configure.incompatibleTargetForSource", 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 IllegalArgumentException(this.bind("configure.incompatibleTargetForSource", 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 IllegalArgumentException(this.bind("configure.incompatibleTargetForSource", 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 IllegalArgumentException(this.bind("configure.incompatibleTargetForSource", targetVersion, CompilerOptions.VERSION_1_4)); //$NON-NLS-1$
- }
// target cannot be greater than compliance level
if (this.complianceLevel < CompilerOptions.versionToJdkLevel(targetVersion)){
throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForTarget", this.options.get(CompilerOptions.OPTION_Compliance), targetVersion)); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/messages.properties
index f393dce99d8..587682122a4 100644
--- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/messages.properties
+++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/messages.properties
@@ -61,7 +61,6 @@ compile.severalClassFilesGenerated = [{0} .class files generated]
compile.failOnWarning = error: warnings found and -failOnWarning specified
### configure
-configure.requiresJDK1.2orAbove = Need to use a JVM >= 1.2
configure.duplicateLog = duplicate log specification: {0}
configure.duplicateRepeat = duplicate repeat specification: {0}
configure.duplicateMaxProblems = duplicate max problems specification: {0}
@@ -71,7 +70,10 @@ configure.duplicateTarget = duplicate target compliance setting specification: {
configure.unsupportedReleaseOption = option --release is supported only when run with JDK 9 or above
configure.unsupportedWithRelease = option {0} is not supported when --release is used
configure.unsupportedReleaseVersion = release version {0} is not supported
-configure.source = source level should be in ''1.1''...''1.8'',''9''...''22'' (or ''5.0''..''22.0''): {0}
+configure.unsupportedComplianceVersion = compliance option {0} is no longer supported. Use {1} or later.
+configure.unsupportedSourceVersion = source option {0} is no longer supported. Use {1} or later.
+configure.unsupportedTargetVersion = target option {0} is no longer supported. Use {1} or later.
+configure.source = source level should be in ''1.8'',''9''...''22'' (or ''8.0''..''22.0''): {0}
configure.invalidSystem = invalid location for system libraries: {0}
configure.unsupportedOption = option {0} not supported at compliance level 9 and above
configure.duplicateOutputPath = duplicate output path specification: {0}
@@ -92,9 +94,8 @@ configure.invalidDebugOption = invalid debug option: {0}
configure.invalidWarningConfiguration = invalid warning configuration: ''{0}''
configure.invalidWarning = invalid warning token: ''{0}''. Ignoring warning and compiling
configure.invalidWarningOption = invalid warning option: ''{0}''. Must specify a warning token
-configure.targetJDK = target level should be in ''1.1''...''1.8'',''9''...''22'' (or ''5.0''..''22.0'') or cldc1.1: {0}
+configure.targetJDK = target level should be in ''1.8'',''9''...''22'' (or ''8.0''..''22.0''): {0}
configure.incompatibleTargetForSource = Target level ''{0}'' is incompatible with source level ''{1}''. A target level ''{1}'' or better is required
-configure.incompatibleTargetForGenericSource = Target level ''{0}'' is incompatible with source level ''{1}''. A source level ''1.5'' or better is required
configure.incompatibleComplianceForSource = Compliance level ''{0}'' is incompatible with source level ''{1}''. A compliance level ''{1}'' or better is required
configure.incompatibleComplianceForTarget = Compliance level ''{0}'' is incompatible with target level ''{1}''. A compliance level ''{1}'' or better is required
configure.repetition = repetition must be a positive integer: {0}
@@ -138,9 +139,7 @@ configure.invalidClassName = invalid class name: {0}
configure.invalidModuleName = invalid module name: {0}
configure.packageConflict = The package {0} is accessible from more than one module: {1}, {2}
configure.unavailableAPT = Unable to load annotation processing manager {0} from classpath.
-configure.incorrectVMVersionforAPT = Annotation processing got disabled, since it requires a 1.6 compliant JVM
-configure.incompatibleSourceForCldcTarget=Target level ''{0}'' is incompatible with source level ''{1}''. A source level ''1.3'' or lower is required
-configure.incompatibleComplianceForCldcTarget=Target level ''{0}'' is incompatible with compliance level ''{1}''. A compliance level ''1.4''or lower is required
+configure.incorrectVMVersionforAPT = Annotation processing got disabled because of unsupported class version
configure.invalidClasspathSection = invalid Class-Path header in manifest of jar file: {0}
configure.multipleClasspathSections = multiple Class-Path headers in manifest of jar file: {0}
configure.missingwarningspropertiesfile=properties file {0} does not exist
@@ -248,11 +247,6 @@ misc.usage = {1} {2}\n\
\ --release compile for a specific VM version\n\
\ \n\
\ Compliance options:\n\
-\ -1.3 use 1.3 compliance (-source 1.3 -target 1.1)\n\
-\ -1.4 + use 1.4 compliance (-source 1.3 -target 1.2)\n\
-\ -1.5 -5 -5.0 use 1.5 compliance (-source 1.5 -target 1.5)\n\
-\ -1.6 -6 -6.0 use 1.6 compliance (-source 1.6 -target 1.6)\n\
-\ -1.7 -7 -7.0 use 1.7 compliance (-source 1.7 -target 1.7)\n\
\ -1.8 -8 -8.0 use 1.8 compliance (-source 1.8 -target 1.8)\n\
\ -1.9 -9 -9.0 use 1.9 compliance (-source 1.9 -target 1.9)\n\
\ -10 -10.0 use 10 compliance (-source 10 -target 10)\n\
@@ -268,12 +262,10 @@ misc.usage = {1} {2}\n\
\ -20 -20.0 use 20 compliance (-source 20 -target 20)\n\
\ -21 -21.0 use 21 compliance (-source 21 -target 21)\n\
\ -22 -22.0 use 22 compliance (-source 22 -target 22)\n\
-\ -source set source level: 1.3 to 1.9, 10 to 22\n\
-\ (or 6, 6.0, etc)\n\
-\ -target set classfile target: 1.3 to 1.9, 10 to 22\n\
-\ (or 6, 6.0, etc)\n\
-\ cldc1.1 can also be used to generate the StackMap\n\
-\ attribute\n\
+\ -source set source level: 1.8, 1.9, 10 to 22\n\
+\ (or 8, 8.0, etc)\n\
+\ -target set classfile target: 1.8, 1.9, 10 to 22\n\
+\ (or 8, 8.0, etc)\n\
\ --enable-preview enable support for preview features of the\n\
\ latest Java release\n\
\ \n\
@@ -316,7 +308,6 @@ misc.usage = {1} {2}\n\
\ -preserveAllLocals preserve unused local vars for debug purpose\n\
\ \n\
\ Annotation processing options:\n\
-\ These options are meaningful only in a 1.6 environment.\n\
\ -Akey[=value] options that are passed to annotation processors\n\
\ -processorpath \n\
\ specify locations where to find annotation processors.\n\
@@ -353,7 +344,6 @@ misc.usage = {1} {2}\n\
\ -noExit do not call System.exit(n) at end of compilation (n==0\n\
\ if no error)\n\
\ -repeat repeat compilation process times for perf analysis\n\
-\ -inlineJSR inline JSR bytecode (implicit if target >= 1.5)\n\
\ -enableJavadoc consider references in javadoc\n\
\ -parameters generate method parameters attribute (for target >= 1.8)\n\
\ -genericsignature generate generic signature for lambda expressions\n\
diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index b9cbec6e126..6228791ec0d 100644
--- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -125,6 +125,7 @@ public class CompilerOptions {
public static final String OPTION_TaskTags = "org.eclipse.jdt.core.compiler.taskTags"; //$NON-NLS-1$
public static final String OPTION_TaskPriorities = "org.eclipse.jdt.core.compiler.taskPriorities"; //$NON-NLS-1$
public static final String OPTION_TaskCaseSensitive = "org.eclipse.jdt.core.compiler.taskCaseSensitive"; //$NON-NLS-1$
+ @Deprecated(forRemoval = true)
public static final String OPTION_InlineJsr = "org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode"; //$NON-NLS-1$
public static final String OPTION_ShareCommonFinallyBlocks = "org.eclipse.jdt.core.compiler.codegen.shareCommonFinallyBlocks"; //$NON-NLS-1$
public static final String OPTION_ReportNullReference = "org.eclipse.jdt.core.compiler.problem.nullReference"; //$NON-NLS-1$
@@ -504,6 +505,7 @@ public class CompilerOptions {
public int reportMissingJavadocCommentsVisibility;
/** Specify if need to flag missing javadoc comment for overriding method */
public boolean reportMissingJavadocCommentsOverriding;
+ @Deprecated
/** Indicate whether the JSR bytecode should be inlined to avoid its presence in classfile */
public boolean inlineJsrBytecode;
/** Indicate whether common escaping finally blocks should be shared */
@@ -1428,7 +1430,6 @@ public Map getMap() {
optionsMap.put(OPTION_ReportUnusedParameterIncludeDocCommentReference, this.reportUnusedParameterIncludeDocCommentReference ? ENABLED : DISABLED);
optionsMap.put(OPTION_ReportSpecialParameterHidingField, this.reportSpecialParameterHidingField ? ENABLED : DISABLED);
optionsMap.put(OPTION_MaxProblemPerUnit, String.valueOf(this.maxProblemsPerUnit));
- optionsMap.put(OPTION_InlineJsr, this.inlineJsrBytecode ? ENABLED : DISABLED);
optionsMap.put(OPTION_ShareCommonFinallyBlocks, this.shareCommonFinallyBlocks ? ENABLED : DISABLED);
optionsMap.put(OPTION_ReportNullReference, getSeverityString(NullReference));
optionsMap.put(OPTION_ReportPotentialNullReference, getSeverityString(PotentialNullReference));
@@ -1577,9 +1578,12 @@ protected void resetDefaults() {
// by default only lines and source attributes are generated.
this.produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
- this.complianceLevel = this.originalComplianceLevel = ClassFileConstants.JDK1_4; // by default be compliant with 1.4
- this.sourceLevel = this.originalSourceLevel = ClassFileConstants.JDK1_3; //1.3 source behavior by default
- this.targetJDK = ClassFileConstants.JDK1_2; // default generates for JVM1.2
+
+ // by default be compliant with first supported version
+ final long firstSupportedJdkLevel = getFirstSupportedJdkLevel();
+ this.complianceLevel = this.originalComplianceLevel = firstSupportedJdkLevel;
+ this.sourceLevel = this.originalSourceLevel = firstSupportedJdkLevel;
+ this.targetJDK = firstSupportedJdkLevel;
this.defaultEncoding = null; // will use the platform default encoding
@@ -1640,7 +1644,7 @@ protected void resetDefaults() {
this.reportMissingJavadocCommentsOverriding = false;
// JSR bytecode inlining and sharing
- this.inlineJsrBytecode = false;
+ this.inlineJsrBytecode = true;
this.shareCommonFinallyBlocks = false;
// javadoc comment support
@@ -1789,7 +1793,7 @@ public void set(Map optionsMap) {
}
this.targetJDK = level;
}
- if (this.targetJDK >= ClassFileConstants.JDK1_5) this.inlineJsrBytecode = true; // forced from 1.5 mode on
+ this.inlineJsrBytecode = true; // forced from 1.5 mode on
}
if ((optionValue = optionsMap.get(OPTION_Encoding)) != null) {
this.defaultEncoding = null;
@@ -1877,15 +1881,6 @@ public void set(Map optionsMap) {
this.isTaskCaseSensitive = false;
}
}
- if ((optionValue = optionsMap.get(OPTION_InlineJsr)) != null) {
- if (this.targetJDK < ClassFileConstants.JDK1_5) { // only optional if target < 1.5 (inlining on from 1.5 on)
- if (ENABLED.equals(optionValue)) {
- this.inlineJsrBytecode = true;
- } else if (DISABLED.equals(optionValue)) {
- this.inlineJsrBytecode = false;
- }
- }
- }
if ((optionValue = optionsMap.get(OPTION_ShareCommonFinallyBlocks)) != null) {
if (ENABLED.equals(optionValue)) {
this.shareCommonFinallyBlocks = true;
@@ -2361,7 +2356,6 @@ public String toString() {
buf.append("\n\t- report unused parameter when overriding concrete method : ").append(this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- report unused parameter include doc comment reference : ").append(this.reportUnusedParameterIncludeDocCommentReference ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? ENABLED : DISABLED); //$NON-NLS-1$
- buf.append("\n\t- inline JSR bytecode : ").append(this.inlineJsrBytecode ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- share common finally blocks : ").append(this.shareCommonFinallyBlocks ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- report unavoidable generic type problems : ").append(this.reportUnavoidableGenericTypeProblems ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- unsafe type operation: ").append(getSeverityString(UncheckedTypeOperation)); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 90e795c0478..d2dbcbc857a 100644
--- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -913,6 +913,16 @@ public void abortDueToPreviewEnablingNotAllowed(String sourceLevel, String expec
0,
0);
}
+public void abortDueToNotSupportedJavaVersion(String notSupportedVersion, String firstSupportedVersion) {
+ String[] args = new String[] {notSupportedVersion, firstSupportedVersion};
+ this.handle(
+ IProblem.JavaVersionNotSupported,
+ args,
+ args,
+ ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
+ 0,
+ 0);
+}
public void abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod) {
this.handle(
diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties
index 11ec07df00a..2d7c5b4160c 100644
--- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -905,6 +905,7 @@
1106 = Preview features enabled at an invalid source release level {0}, preview can be enabled only at source level {1}
1107 = The Java feature ''{0}'' is only available with source level {1} and above
1108 = You are using an API that is part of a preview feature and may be removed in future
+1109 = Compiling for Java version ''{0}'' is no longer supported. Minimal supported version is ''{1}''
# more programming problems:
1200 = Unlikely argument type {0} for {1} on a {2}
1201 = Unlikely argument type for equals(): {0} seems to be unrelated to {2}
diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java
index 7e67248b886..f457cfaaacd 100644
--- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java
+++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java
@@ -811,6 +811,7 @@ public boolean handleOption(String current, Iterator remaining) {
}
case "-extdirs": //$NON-NLS-1$
if (this.isOnJvm9) {
+ // XXX this should check -target == 8, not the running JVM version!
throw new IllegalArgumentException();
}
if (remaining.hasNext()) {
diff --git a/org.eclipse.jdt.core.tests.builder/pom.xml b/org.eclipse.jdt.core.tests.builder/pom.xml
index d1d0d0079ab..83e8cd831b7 100644
--- a/org.eclipse.jdt.core.tests.builder/pom.xml
+++ b/org.eclipse.jdt.core.tests.builder/pom.xml
@@ -60,7 +60,7 @@