From 709e6b9659fe3e75d45865ada1948c528aaaaf18 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Mon, 15 Jul 2024 16:08:44 +0200 Subject: [PATCH 1/4] Remove compiler support for JLS source/target < 1.8 Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2536 --- .../tool/tests/CompilerInvocationTests.java | 7 +- .../eclipse/jdt/core/compiler/IProblem.java | 2 + .../jdt/internal/compiler/Compiler.java | 20 ++ .../jdt/internal/compiler/batch/Main.java | 296 ++---------------- .../compiler/batch/messages.properties | 30 +- .../compiler/impl/CompilerOptions.java | 9 +- .../compiler/problem/ProblemReporter.java | 10 + .../compiler/problem/messages.properties | 1 + org.eclipse.jdt.core.tests.builder/pom.xml | 6 +- .../jdt/core/tests/builder/BuilderTests.java | 4 +- .../core/tests/builder/BuildpathTests.java | 32 -- .../core/tests/builder/DependencyTests.java | 5 +- .../tests/builder/TestingEnvironment.java | 18 +- org.eclipse.jdt.core.tests.compiler/pom.xml | 10 +- .../parser/AnnotationDietRecoveryTest.java | 11 +- .../tests/compiler/parser/ParserTest1_7.java | 2 +- .../parser/RunCompletionParserTests.java | 53 ---- .../core/tests/compiler/parser/TestAll.java | 29 -- .../regression/AbstractComparableTest.java | 2 +- .../regression/AbstractRegressionTest.java | 3 +- .../compiler/regression/AssertionTest.java | 2 +- .../regression/AssignmentTest_1_5.java | 2 +- .../regression/AssignmentTest_1_7.java | 2 +- .../regression/BatchCompilerTest.java | 2 +- .../regression/BinaryLiteralTest.java | 2 +- .../BootstrapMethodAttributeTest.java | 2 +- .../regression/ClassFileReaderTest_1_4.java | 6 +- .../regression/ClassFileReaderTest_1_5.java | 2 +- .../compiler/regression/Compliance_1_3.java | 2 +- .../compiler/regression/Compliance_1_4.java | 2 +- .../compiler/regression/Compliance_1_5.java | 29 +- .../compiler/regression/Compliance_1_6.java | 8 +- .../compiler/regression/Compliance_1_7.java | 26 +- .../compiler/regression/Compliance_CLDC.java | 15 +- .../ConcurrentBatchCompilerTest.java | 8 +- .../compiler/regression/Deprecated15Test.java | 2 +- .../ExternalizeStringLiteralsTest_1_5.java | 3 +- .../regression/GenericTypeSignatureTest.java | 2 +- .../GenericsRegressionTest_1_7.java | 6 +- .../compiler/regression/InnerClass15Test.java | 2 +- .../regression/InnerEmulationTest_1_5.java | 2 +- .../regression/InternalHexFloatTest.java | 2 +- .../compiler/regression/JavadocTest.java | 12 +- .../compiler/regression/JavadocTest_1_3.java | 2 +- .../compiler/regression/JavadocTest_1_4.java | 2 +- .../compiler/regression/JavadocTest_1_5.java | 2 +- .../tests/compiler/regression/Jsr14Test.java | 8 +- .../compiler/regression/MethodHandleTest.java | 2 +- .../NullAnnotationBatchCompilerTest.java | 30 +- .../regression/PolymorphicSignatureTest.java | 2 +- .../ResourceLeakAnnotatedTests.java | 2 +- .../regression/StackMapAttributeTest.java | 13 +- .../regression/SuppressWarningsTest.java | 11 +- .../tests/compiler/regression/TestAll.java | 48 +-- .../regression/TryStatement17Test.java | 2 +- .../TryWithResourcesStatementTest.java | 16 +- .../regression/UnderscoresInLiteralsTest.java | 8 +- .../compiler/regression/XLargeTest2.java | 2 +- .../core/tests/util/AbstractCompilerTest.java | 86 +---- org.eclipse.jdt.core.tests.compiler/test.xml | 2 +- org.eclipse.jdt.core.tests.model/pom.xml | 8 +- .../tests/model/AbstractJavaModelTests.java | 5 - .../model/org/eclipse/jdt/core/JavaCore.java | 53 +--- 63 files changed, 243 insertions(+), 752 deletions(-) diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java index 91572fd3e34..b59aa6efae5 100644 --- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java +++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java @@ -44,6 +44,7 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import junit.framework.Test; @@ -57,7 +58,7 @@ public CompilerInvocationTests(String name) { super(name); } public static Test suite() { - return buildUniqueComplianceTestSuite(CompilerInvocationTests.class, ClassFileConstants.JDK1_6); + return buildUniqueComplianceTestSuite(CompilerInvocationTests.class, CompilerOptions.getFirstSupportedJdkLevel()); } public static Class testClass() { return CompilerInvocationTests.class; @@ -81,7 +82,7 @@ protected void checkClassFiles(String[] fileNames) { fail("IO exception for file " + fileNames[i]); } assertNotNull("Could not read " + fileNames[i], reader); - assertEquals("Wrong Java version for " + fileNames[i], ClassFileConstants.JDK1_6, reader.getVersion()); + assertEquals("Wrong Java version for " + fileNames[i], ClassFileConstants.JDK1_8, reader.getVersion()); } } void runTest( @@ -96,7 +97,7 @@ void runTest( String[] classFileNames) { List opt = options == null ? new ArrayList<>() : new ArrayList<>(options); opt.add("-source"); - opt.add("1.6"); + opt.add("1.8"); super.runTest( shouldCompileOK, sourceFiles, diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler/IProblem.java index d7a0139da84..9b8f00dc827 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler/IProblem.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/core/compiler/IProblem.java @@ -2183,6 +2183,8 @@ public interface IProblem { int FeatureNotSupported = Compliance + 1107; /** @since 3.26*/ int PreviewAPIUsed = Compliance + 1108; + /** @since 3.39*/ + int JavaVersionNotSupported = Compliance + 1109; /** @since 3.13 */ int UnlikelyCollectionMethodArgumentType = 1200; diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java index 23c5284d8b8..9b0c94eeaf8 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java @@ -818,11 +818,31 @@ private void abortIfPreviewNotAllowed(ICompilationUnit[] sourceUnits, int maxUn throw a; } } + + private void abortIfVersionNotAllowed(ICompilationUnit[] sourceUnits, int maxUnits) { + try { + long firstSupportedJdkLevel = CompilerOptions.getFirstSupportedJdkLevel(); + if (this.options.sourceLevel < firstSupportedJdkLevel + || this.options.targetJDK < firstSupportedJdkLevel + || this.options.complianceLevel < firstSupportedJdkLevel) { + long badVersion = Math.min(this.options.complianceLevel, Math.min(this.options.sourceLevel, this.options.targetJDK)); + this.problemReporter.abortDueToNotSupportedJavaVersion(CompilerOptions.versionFromJdkLevel(badVersion), + CompilerOptions.getFirstSupportedJavaVersion()); + } + } catch (AbortCompilation a) { + // best effort to find a way for reporting this problem: report on the first source + if (a.compilationResult == null) { + a.compilationResult = new CompilationResult(sourceUnits[0], 0, maxUnits, this.options.maxProblemsPerUnit); + } + throw a; + } + } /** * Add the initial set of compilation units into the loop * -> build compilation unit declarations, their bindings and record their results. */ protected void internalBeginToCompile(ICompilationUnit[] sourceUnits, int maxUnits) { + abortIfVersionNotAllowed(sourceUnits,maxUnits); abortIfPreviewNotAllowed(sourceUnits,maxUnits); if (!this.useSingleThread) this.parser.readManager = new ReadManager(sourceUnits, maxUnits); diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java index fe61cebfa6a..1e02b7e6206 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java @@ -1071,18 +1071,6 @@ public void logVersion(final boolean printToOut) { } } - /** - * Print the usage of wrong JDK - */ - public void logWrongJDK() { - if ((this.tagBits & Logger.XML) != 0) { - HashMap 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..e032d6eebe4 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 @@ -1577,9 +1577,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 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.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 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,17 + --add-modules ALL-SYSTEM -Dcompliance=1.8,17 @@ -81,7 +81,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,21 + --add-modules ALL-SYSTEM -Dcompliance=1.8,21 @@ -102,7 +102,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,21,22 + --add-modules ALL-SYSTEM -Dcompliance=1.8,21,22 diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java index eceb87cca67..c5b79bad4f0 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java @@ -548,13 +548,11 @@ private static Class[] getAllTestClasses() { LeakTestsBefore9.class, }; List> list = new ArrayList<>(Arrays.asList(classes)); - if (matchesCompliance(F_1_5)) { + if (matchesCompliance(F_1_8)) { list.add(Java50Tests.class); list.add(PackageInfoTest.class); list.add(ParticipantBuildTests.class); list.add(AnnotationDependencyTests.class); - } - if (matchesCompliance(F_1_8)) { list.add(Bug544921Test.class); } if (matchesCompliance(F_9)) { diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java index e5192c47824..30854f39544 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java @@ -34,7 +34,6 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CategorizedProblem; -import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.core.JavaModel; @@ -993,37 +992,6 @@ public void testMissingOptionalProject() throws JavaModelException { env.removeProject(project2Path); } -// https://bugs.eclipse.org/bugs/show_bug.cgi?id=160132 -public void test0100() throws JavaModelException { - if (!AbstractCompilerTest.isJRELevel(AbstractCompilerTest.F_1_5)) { - // expected to run only in 1.5 mode on top of a jre 1.5 or above - return; - } - IPath projectPath = env.addProject("P", "1.5"); - IPath defaultPackagePath = env.addPackage(projectPath, ""); - env.addExternalJars(projectPath, Util.getJavaClassLibs()); - env.addClass(defaultPackagePath, "X", - "public interface X {\n" + - " interface Entry {\n" + - " interface Internal extends Entry {\n" + - " Internal createEntry();\n" + - " }\n" + - " }\n" + - "}" - ); - fullBuild(); - expectingNoProblems(); - env.addClass(defaultPackagePath, "Y", - "public class Y implements X.Entry.Internal {\n" + - " public Internal createEntry() {\n" + - " return null;\n" + - " }\n" + - "}"); - incrementalBuild(); - expectingNoProblems(); - env.removeProject(projectPath); -} - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=143025 public void testMissingOutputFolder() throws JavaModelException { IPath projectPath = env.addProject("P"); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java index 07de7950983..11612630ca6 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java @@ -22,6 +22,7 @@ import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({"rawtypes", "unchecked"}) public class DependencyTests extends BuilderTests { @@ -1149,9 +1150,9 @@ public void testTypeVisibility2() throws JavaModelException { } public void testTypeVariable() throws JavaModelException { - if ((AbstractCompilerTest.getPossibleComplianceLevels() & AbstractCompilerTest.F_1_5) == 0) return; + if ((AbstractCompilerTest.getPossibleComplianceLevels() & AbstractCompilerTest.FIRST_SUPPORTED_JAVA_VERSION) == 0) return; - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java index 08398b3ba18..58add6257d7 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java @@ -181,7 +181,7 @@ public void addProject(IProject project){ } public IPath addProject(String projectName){ - return addProject(projectName, "1.4"); + return addProject(projectName, CompilerOptions.getFirstSupportedJavaVersion()); } public IPath addProject(String projectName, String compliance){ @@ -189,19 +189,7 @@ public IPath addProject(String projectName, String compliance){ IProject project = createProject(projectName); int requiredComplianceFlag = 0; String compilerVersion = null; - if ("1.5".equals(compliance)) { - requiredComplianceFlag = AbstractCompilerTest.F_1_5; - compilerVersion = CompilerOptions.VERSION_1_5; - } - else if ("1.6".equals(compliance)) { - requiredComplianceFlag = AbstractCompilerTest.F_1_6; - compilerVersion = CompilerOptions.VERSION_1_6; - } - else if ("1.7".equals(compliance)) { - requiredComplianceFlag = AbstractCompilerTest.F_1_7; - compilerVersion = CompilerOptions.VERSION_1_7; - } - else if ("1.8".equals(compliance)) { + if ("1.8".equals(compliance)) { requiredComplianceFlag = AbstractCompilerTest.F_1_8; compilerVersion = CompilerOptions.VERSION_1_8; } @@ -241,7 +229,7 @@ else if ("12".equals(compliance)) { } else if ("19".equals(compliance)) { requiredComplianceFlag = AbstractCompilerTest.F_19; compilerVersion = CompilerOptions.VERSION_19; - } else if (!"1.4".equals(compliance) && !"1.3".equals(compliance)) { + } else { throw new UnsupportedOperationException("Test framework doesn't support compliance level: " + compliance); } if (requiredComplianceFlag != 0) { diff --git a/org.eclipse.jdt.core.tests.compiler/pom.xml b/org.eclipse.jdt.core.tests.compiler/pom.xml index 0cdf0485769..b897b753f34 100644 --- a/org.eclipse.jdt.core.tests.compiler/pom.xml +++ b/org.eclipse.jdt.core.tests.compiler/pom.xml @@ -62,7 +62,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,14,17 + --add-modules ALL-SYSTEM -Dcompliance=1.8,14,17 @@ -83,7 +83,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,15,18 + --add-modules ALL-SYSTEM -Dcompliance=1.8,15,18 @@ -104,7 +104,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,17,19 + --add-modules ALL-SYSTEM -Dcompliance=1.8,17,19 @@ -125,7 +125,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,17,20 + --add-modules ALL-SYSTEM -Dcompliance=1.8,17,20 @@ -146,7 +146,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.8,17,19,21 + --add-modules ALL-SYSTEM -Dcompliance=1.8,17,19,21 diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java index 40589f6b455..552e9e91756 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java @@ -26,7 +26,6 @@ import org.eclipse.jdt.internal.compiler.SourceElementParser; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.parser.Parser; @@ -40,13 +39,13 @@ public class AnnotationDietRecoveryTest extends AbstractCompilerTest { private static final boolean CHECK_ALL_PARSE = true; public static boolean optimizeStringLiterals = false; - public static long sourceLevel = ClassFileConstants.JDK1_3; //$NON-NLS-1$ + public static long sourceLevel = CompilerOptions.getFirstSupportedJdkLevel(); //$NON-NLS-1$ public AnnotationDietRecoveryTest(String testName){ super(testName); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { return AnnotationDietRecoveryTest.class; @@ -57,9 +56,9 @@ public static Class testClass() { @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); return options; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java index 2afedae706d..7293067d43e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java @@ -43,7 +43,7 @@ public static Class testClass() { return ParserTest1_7.class; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public ParserTest1_7(String testName){ super(testName); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java index 94bc5590246..adfe1ba55a9 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java @@ -61,59 +61,6 @@ public static Test suite() { TestSuite all = new TestSuite(TestAll.class.getName()); int possibleComplianceLevels = AbstractCompilerTest.getPossibleComplianceLevels(); - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_3) != 0) { - ArrayList tests_1_3 = (ArrayList)testClasses.clone(); - // Reset forgotten subsets tests - TestCase.TESTS_PREFIX = null; - TestCase.TESTS_NAMES = null; - TestCase.TESTS_NUMBERS= null; - TestCase.TESTS_RANGE = null; - TestCase.RUN_ONLY_ID = null; - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_3, tests_1_3)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_4) != 0) { - ArrayList tests_1_4 = (ArrayList)testClasses.clone(); - // Reset forgotten subsets tests - TestCase.TESTS_PREFIX = null; - TestCase.TESTS_NAMES = null; - TestCase.TESTS_NUMBERS= null; - TestCase.TESTS_RANGE = null; - TestCase.RUN_ONLY_ID = null; - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_4, tests_1_4)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_5) != 0) { - ArrayList tests_1_5 = (ArrayList)testClasses.clone(); - tests_1_5.addAll(TEST_CLASSES_1_5); - // Reset forgotten subsets tests - TestCase.TESTS_PREFIX = null; - TestCase.TESTS_NAMES = null; - TestCase.TESTS_NUMBERS= null; - TestCase.TESTS_RANGE = null; - TestCase.RUN_ONLY_ID = null; - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_5, tests_1_5)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_6) != 0) { - ArrayList tests_1_6 = (ArrayList)testClasses.clone(); - tests_1_6.addAll(TEST_CLASSES_1_5); - // Reset forgotten subsets tests - TestCase.TESTS_PREFIX = null; - TestCase.TESTS_NAMES = null; - TestCase.TESTS_NUMBERS= null; - TestCase.TESTS_RANGE = null; - TestCase.RUN_ONLY_ID = null; - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_6, tests_1_6)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_7) != 0) { - ArrayList tests_1_7 = (ArrayList)testClasses.clone(); - tests_1_7.addAll(TEST_CLASSES_1_5); - // Reset forgotten subsets tests - TestCase.TESTS_PREFIX = null; - TestCase.TESTS_NAMES = null; - TestCase.TESTS_NUMBERS= null; - TestCase.TESTS_RANGE = null; - TestCase.RUN_ONLY_ID = null; - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_7, tests_1_7)); - } if ((possibleComplianceLevels & AbstractCompilerTest.F_1_8) != 0) { ArrayList tests_1_8 = (ArrayList)testClasses.clone(); tests_1_8.addAll(TEST_CLASSES_1_5); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java index 2d560be188b..c2c471e5c88 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java @@ -83,35 +83,6 @@ public static TestSuite getTestSuite(boolean addComplianceDiagnoseTest) { TestSuite all = new TestSuite(TestAll.class.getName()); int possibleComplianceLevels = AbstractCompilerTest.getPossibleComplianceLevels(); - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_3) != 0) { - ArrayList tests_1_3 = (ArrayList)testClasses.clone(); - TestCase.resetForgottenFilters(tests_1_3); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_3, tests_1_3)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_4) != 0) { - ArrayList tests_1_4 = (ArrayList)testClasses.clone(); - TestCase.resetForgottenFilters(tests_1_4); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_4, tests_1_4)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_5) != 0) { - ArrayList tests_1_5 = (ArrayList)testClasses.clone(); - tests_1_5.addAll(TEST_CLASSES_1_5); - TestCase.resetForgottenFilters(tests_1_5); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_5, tests_1_5)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_6) != 0) { - ArrayList tests_1_6 = (ArrayList)testClasses.clone(); - tests_1_6.addAll(TEST_CLASSES_1_5); - TestCase.resetForgottenFilters(tests_1_6); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_6, tests_1_6)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_7) != 0) { - ArrayList tests_1_7 = (ArrayList)testClasses.clone(); - tests_1_7.addAll(TEST_CLASSES_1_5); - tests_1_7.add(ParserTest1_7.class); - TestCase.resetForgottenFilters(tests_1_7); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_7, tests_1_7)); - } if ((possibleComplianceLevels & AbstractCompilerTest.F_1_8) != 0) { ArrayList tests_1_8 = (ArrayList)testClasses.clone(); tests_1_8.addAll(TEST_CLASSES_1_5); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java index 48504c3e61f..4865570baf2 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java @@ -97,7 +97,7 @@ public class AbstractComparableTest extends AbstractRegressionTest { "}"; public static Test buildComparableTestSuite(Class evaluationTestClass) { - Test suite = buildMinimalComplianceTestSuite(evaluationTestClass, F_1_5); + Test suite = buildMinimalComplianceTestSuite(evaluationTestClass, FIRST_SUPPORTED_JAVA_VERSION); TESTS_COUNTERS.put(evaluationTestClass.getName(), Integer.valueOf(suite.countTestCases())); return suite; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java index 2c90b881a22..77319b4e245 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java @@ -4078,7 +4078,8 @@ protected void setUp() throws Exception { String version = JavacCompiler.getVersion(cmdLineHeader.toString()); cmdLineHeader.append(" -d "); cmdLineHeader.append(JAVAC_OUTPUT_DIR_NAME.indexOf(" ") != -1 ? "\"" + JAVAC_OUTPUT_DIR_NAME + "\"" : JAVAC_OUTPUT_DIR_NAME); - cmdLineHeader.append(" -source 1.5 -deprecation -Xlint "); // enable recommended warnings + String firstSupportedVersion = CompilerOptions.getFirstSupportedJavaVersion(); + cmdLineHeader.append(" -source " + firstSupportedVersion + " -deprecation -Xlint "); // enable recommended warnings // WORK new javac system does not do that... reconsider // REVIEW consider enabling all warnings instead? Philippe does not see // this as ez to use (too many changes in logs) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java index d151a04b531..46fcf009f36 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java @@ -31,7 +31,7 @@ public AssertionTest(String name) { } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_4); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_5.java index fb8a22161c0..6dafc7c59ed 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_5.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_5.java @@ -42,7 +42,7 @@ protected Map getCompilerOptions() { // TESTS_RANGE = new int[] { 11, -1 }; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=277450 public void test1() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java index a49aa3f0d12..d8b1b4bfbee 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java @@ -42,7 +42,7 @@ protected Map getCompilerOptions() { // TESTS_RANGE = new int[] { 11, -1 }; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } /* * no effect assignment bug diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java index 9aa93bd9040..686fc520375 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java @@ -85,7 +85,7 @@ public BatchCompilerTest(String name) { * @see TestAll */ public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { return BatchCompilerTest.class; diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BinaryLiteralTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BinaryLiteralTest.java index 954bfd9b64a..ccc550922fe 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BinaryLiteralTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BinaryLiteralTest.java @@ -25,7 +25,7 @@ public BinaryLiteralTest(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BootstrapMethodAttributeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BootstrapMethodAttributeTest.java index c4bd218e5b5..99f74244b97 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BootstrapMethodAttributeTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BootstrapMethodAttributeTest.java @@ -40,7 +40,7 @@ public static Class testClass() { // TESTS_RANGE = new int[] { 23 -1,}; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public void test001() throws Exception { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_4.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_4.java index 978347aca25..8a9f05f3894 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_4.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_4.java @@ -17,8 +17,8 @@ import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.env.IBinaryMethod; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({ "rawtypes" }) public class ClassFileReaderTest_1_4 extends AbstractRegressionTest { @@ -29,7 +29,7 @@ public class ClassFileReaderTest_1_4 extends AbstractRegressionTest { } public static Test suite() { - return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_4); + return buildUniqueComplianceTestSuite(testClass(), CompilerOptions.getFirstSupportedJdkLevel()); } public static Class testClass() { return ClassFileReaderTest_1_4.class; @@ -2604,7 +2604,7 @@ public void test069() throws Exception { "public interface I {\n" + "}"; String expectedOutput = - "// Compiled from I.java (version 1.2 : 46.0, no super bit)\n" + + "// Compiled from I.java (version 1.8 : 52.0, no super bit)\n" + "public abstract interface I {\n" + " Constant pool:\n" + " constant #1 class: #2 I\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_5.java index 092de4cacb6..3c2eee92f74 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_5.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_5.java @@ -35,7 +35,7 @@ public class ClassFileReaderTest_1_5 extends AbstractRegressionTest { } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { return ClassFileReaderTest_1_5.class; diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java index 07544df301b..37475405d62 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java @@ -50,7 +50,7 @@ protected Map getCompilerOptions() { return options; } public static Test suite() { - return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_3); + return buildUniqueComplianceTestSuite(testClass(), CompilerOptions.getFirstSupportedJdkLevel()); } public static Class testClass() { return Compliance_1_3.class; diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java index e5f7e6df34f..f343f8481d3 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java @@ -47,7 +47,7 @@ protected Map getCompilerOptions() { return options; } public static Test suite() { - return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_4); + return buildUniqueComplianceTestSuite(testClass(), CompilerOptions.getFirstSupportedJdkLevel()); } public static Class testClass() { return Compliance_1_4.class; diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java index cb4e20cae9c..d9a9d783ded 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java @@ -16,15 +16,14 @@ import java.io.File; import java.util.Map; -import junit.framework.Test; - import org.eclipse.jdt.core.ToolFactory; -import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import junit.framework.Test; + @SuppressWarnings({ "unchecked", "rawtypes" }) public class Compliance_1_5 extends AbstractComparableTest { boolean docSupport = false; @@ -3004,28 +3003,7 @@ public void test087() { ); } public void test088() { - String errorMessage = - "----------\n" + - "1. WARNING in p\\X.java (at line 4)\n" + - " public class X extends Date implements Runnable{\n" + - " ^\n" + - "The serializable class X does not declare a static final serialVersionUID field of type long\n" + - "----------\n" + - "2. ERROR in p\\X.java (at line 12)\n" + - " this.super();\n" + - " ^^^^\n" + - "Illegal enclosing instance specification for type Object\n" + - "----------\n" + - "3. WARNING in p\\X.java (at line 39)\n" + - " Method _getMethod = c.getMethod(\"d\",null);\n" + - " ^^^^^^^^^^^^^^^^^^^^^\n" + - "Type null of the last argument to method getMethod(String, Class...) doesn't exactly match the vararg parameter type. Cast to Class[] to confirm the non-varargs invocation, or pass individual arguments of type Class for a varargs invocation.\n" + - "----------\n"; - String javaVersion = System.getProperty("java.version"); - int allPossibleLevels = getPossibleComplianceLevels(); - boolean isLevelGreaterThan5 = (allPossibleLevels & ~(F_1_3 | F_1_4 | F_1_5)) != 0; - if (isLevelGreaterThan5 - || (allPossibleLevels == AbstractCompilerTest.F_1_5 && javaVersion.indexOf("1.5") == -1)) { + String errorMessage; errorMessage = "----------\n" + "1. WARNING in p\\X.java (at line 4)\n" + @@ -3048,7 +3026,6 @@ public void test088() { " ^^^^^^^^^^^^^^^^^^^^^\n" + "Type safety: The method getMethod(String, Class...) belongs to the raw type Class. References to generic type Class should be parameterized\n" + "----------\n"; - } this.runNegativeTest( new String[] { "p/X.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_6.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_6.java index 14ace54a060..2020fbe8b51 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_6.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_6.java @@ -26,7 +26,7 @@ public Compliance_1_6(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_6); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } // Use this static initializer to specify subset for tests // All specified tests which does not belong to the class are skipped... @@ -41,9 +41,9 @@ public static Test suite() { //https://bugs.eclipse.org/bugs/show_bug.cgi?id=283225 public void test1() { Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); this.runConformTest( new String[] { "Test.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_7.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_7.java index 654f9bae4ed..3bf6b9540ea 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_7.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_7.java @@ -29,7 +29,7 @@ public Compliance_1_7(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } static { // Names of tests to run: can be "testBugXXXX" or "BugXXXX") @@ -85,9 +85,9 @@ public void test2() { // regular case public void testBug390889_a() { Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); this.runConformTest( new String[] { "MyComp.java", @@ -130,9 +130,9 @@ public void testBug390889_b() { }); Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); this.runConformTest( new String[] { "C1.java", @@ -160,9 +160,9 @@ public void testBug390889_c() { }); Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); this.runConformTest( new String[] { "CI.java", @@ -186,9 +186,9 @@ public void testBug490988() { if (this.complianceLevel < ClassFileConstants.JDK1_8) return; Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); this.runNegativeTest( new String[] { "Thing.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_CLDC.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_CLDC.java index 56f06b69b44..20c7fb55063 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_CLDC.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_CLDC.java @@ -18,7 +18,6 @@ import junit.framework.Test; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({ "unchecked", "rawtypes" }) @@ -34,13 +33,13 @@ public Compliance_CLDC(String name) { @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_CLDC1_1); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); return options; } public static Test suite() { - return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_3); + return buildUniqueComplianceTestSuite(testClass(), CompilerOptions.getFirstSupportedJdkLevel()); } public static Class testClass() { return Compliance_CLDC.class; @@ -231,7 +230,7 @@ public void test003() throws Exception { "true"); String expectedOutput = - "// Compiled from X.java (version 1.1 : 45.3, super bit)\n" + + "// Compiled from X.java (version 1.8 : 52.0, super bit)\n" + "public class X {\n" + " \n" + " // Method descriptor #6 ()V\n" + @@ -261,8 +260,8 @@ public void test003() throws Exception { " [pc: 17, line: 5]\n" + " Local variable table:\n" + " [pc: 0, pc: 18] local: args index: 0 type: java.lang.String[]\n" + - " Stack map : number of frames 2\n" + - " [pc: 13, full, stack: {java.io.PrintStream}, locals: {java.lang.String[]}]\n" + + " Stack map table: number of frames 2\n" + + " [pc: 13, same_locals_1_stack_item, stack: {java.io.PrintStream}]\n" + " [pc: 14, full, stack: {java.io.PrintStream, int}, locals: {java.lang.String[]}]\n" + "}"; checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConcurrentBatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConcurrentBatchCompilerTest.java index 202ee51af25..470628294ce 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConcurrentBatchCompilerTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConcurrentBatchCompilerTest.java @@ -20,14 +20,13 @@ import junit.framework.Test; import org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({ "unchecked", "rawtypes" }) public class ConcurrentBatchCompilerTest extends BatchCompilerTest { public static Test suite() { - return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_6); + return buildUniqueComplianceTestSuite(testClass(), CompilerOptions.getFirstSupportedJdkLevel()); } public static Class testClass() { return ConcurrentBatchCompilerTest.class; @@ -81,6 +80,7 @@ public void testBug372319() throws Throwable { // collect exceptions indicating a failure: final Throwable[] thrown = new Throwable[2]; + final String firstSupportedVersion = CompilerOptions.getFirstSupportedJavaVersion(); this.runner1 = new Thread(new Runnable() { @Override public void run() { @@ -147,7 +147,7 @@ public void run() { "" }, "\"" + OUTPUT_DIR + File.separator + "org/eclipse/jdt/internal/launching/CompositeId.java\"" - + " -1.5 -g -preserveAllLocals" + + " -" + firstSupportedVersion + " -g -preserveAllLocals" + " -proceedOnError -d \"" + OUTPUT_DIR + "\"", "", "", @@ -189,7 +189,7 @@ public void run() { "}\n" }, "\"" + OUTPUT_DIR + File.separator + "test01/X.java\"" - + " -1.5 -g -preserveAllLocals -err:+resource" + + " -" + firstSupportedVersion + " -g -preserveAllLocals -err:+resource" + " -proceedOnError -d \"" + OUTPUT_DIR + "\"", "", errorOutput.toString(), diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java index b5666dfbec9..18dddc2746b 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java @@ -30,7 +30,7 @@ public Deprecated15Test(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public void test001() { Map options = getCompilerOptions(); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiteralsTest_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiteralsTest_1_5.java index 31cc9e40e33..1102b0a7b4e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiteralsTest_1_5.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiteralsTest_1_5.java @@ -17,7 +17,6 @@ import junit.framework.Test; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({ "unchecked", "rawtypes" }) @@ -32,7 +31,7 @@ public ExternalizeStringLiteralsTest_1_5(String name) { super(name); } public static Test suite() { - return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_5); + return buildUniqueComplianceTestSuite(testClass(), CompilerOptions.getFirstSupportedJdkLevel()); } public void test001() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java index cc6c220490d..4f7f40c03aa 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java @@ -79,7 +79,7 @@ public void run() { // TESTS_RANGE = new int[] { 21, 50 }; // } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java index b98bc07988d..735f93b6ef1 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java @@ -38,7 +38,7 @@ public GenericsRegressionTest_1_7(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public void test001() { this.runConformTest( @@ -2600,7 +2600,7 @@ public void test0059() { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=351965 public void test0060() { Map customOptions = getCompilerOptions(); - customOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); + customOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); this.runNegativeTest( new String[] { "X.java", @@ -2631,7 +2631,7 @@ public void test0060() { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=351965 public void test0060a() { Map customOptions = getCompilerOptions(); - customOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); + customOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); this.runNegativeTest( new String[] { "X.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java index fca62f6f3b4..ddc706c0c02 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java @@ -29,7 +29,7 @@ public InnerClass15Test(String name) { //TESTS_NAMES = new String[] {"testBug520874"}; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } @Override protected Map getCompilerOptions() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest_1_5.java index c27db471e6b..d7bbbb3cb15 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest_1_5.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest_1_5.java @@ -29,7 +29,7 @@ public InnerEmulationTest_1_5(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381 public void test1() throws Exception { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InternalHexFloatTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InternalHexFloatTest.java index d5bd8473563..ba907176fec 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InternalHexFloatTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InternalHexFloatTest.java @@ -45,7 +45,7 @@ public InternalHexFloatTest(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java index aa44a2d748a..2ac3334f0b9 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java @@ -74,14 +74,10 @@ public static Test suite() { testSuite.addTest(suite); } int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels(); - if ((complianceLevels & AbstractCompilerTest.F_1_3) != 0) { - testSuite.addTest(buildUniqueComplianceTestSuite(JavadocTest_1_3.class, ClassFileConstants.JDK1_3)); - } - if ((complianceLevels & AbstractCompilerTest.F_1_4) != 0) { - testSuite.addTest(buildUniqueComplianceTestSuite(JavadocTest_1_4.class, ClassFileConstants.JDK1_4)); - } - if ((complianceLevels & AbstractCompilerTest.F_1_5) != 0) { - testSuite.addTest(buildUniqueComplianceTestSuite(JavadocTest_1_5.class, ClassFileConstants.JDK1_5)); + if ((complianceLevels & AbstractCompilerTest.F_1_8) != 0) { + testSuite.addTest(buildUniqueComplianceTestSuite(JavadocTest_1_3.class, ClassFileConstants.JDK1_8)); + testSuite.addTest(buildUniqueComplianceTestSuite(JavadocTest_1_4.class, ClassFileConstants.JDK1_8)); + testSuite.addTest(buildUniqueComplianceTestSuite(JavadocTest_1_5.class, ClassFileConstants.JDK1_8)); } if ((complianceLevels & AbstractCompilerTest.F_9) != 0) { testSuite.addTest(buildUniqueComplianceTestSuite(JavadocTestForModule.class, ClassFileConstants.JDK9)); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java index c15236a43bd..a9e259513b9 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java @@ -47,7 +47,7 @@ public static Class testClass() { // TESTS_RANGE = new int[] { 21, 50 }; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_3); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } @Override diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java index 75d97648f26..88b4237cf48 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java @@ -48,7 +48,7 @@ public static Class testClass() { // TESTS_RANGE = new int[] { 21, 50 }; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_4); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } @Override diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java index 24393eb8ffc..4f61ec67be8 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java @@ -47,7 +47,7 @@ public static Class testClass() { // TESTS_RANGE = new int[] { 23, -1 }; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } @Override diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Jsr14Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Jsr14Test.java index 308c972c969..96d65ff55ba 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Jsr14Test.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Jsr14Test.java @@ -29,9 +29,9 @@ public Jsr14Test(String name) { @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); return options; } // Static initializer to specify tests subset using TESTS_* static variables @@ -42,7 +42,7 @@ protected Map getCompilerOptions() { // TESTS_RANGE = new int[] { 11, -1 }; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_4); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=277450 public void test1() throws Exception { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodHandleTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodHandleTest.java index 8787aa15310..e6cf5492315 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodHandleTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodHandleTest.java @@ -28,7 +28,7 @@ public MethodHandleTest(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationBatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationBatchCompilerTest.java index a3362d05133..217631d996b 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationBatchCompilerTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationBatchCompilerTest.java @@ -114,7 +114,7 @@ public class NullAnnotationBatchCompilerTest extends AbstractBatchCompilerTest { * @see TestAll */ public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { @@ -165,7 +165,7 @@ public void test314_warn_options() { }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -err:+nullAnnot -warn:-null -err:+nonnullNotRepeated -proc:none -d \"" + OUTPUT_DIR + "\"", "", "----------\n" + @@ -220,7 +220,7 @@ public void test315_warn_options() { }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot -warn:+null -missingNullDefault -proc:none -d \"" + OUTPUT_DIR + "\"", "", "", @@ -246,7 +246,7 @@ public void test315_warn_options_a() { }, "\"" + OUTPUT_DIR + File.separator + "p1" + File.separator + "X1.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot -warn:+null -missingNullDefault -proc:none -d \"" + OUTPUT_DIR + "\"", "", "----------\n" + @@ -277,7 +277,7 @@ public void test315_warn_options_b() { }, "\"" + OUTPUT_DIR + File.separator + "X1.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot -warn:+null -missingNullDefault -proc:none -d \"" + OUTPUT_DIR + "\"", "", "----------\n" + @@ -315,7 +315,7 @@ public void test316_warn_options() { }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot(foo|bar) -warn:+null -nonNullByDefault -proc:none -d \"" + OUTPUT_DIR + "\"", "", "Token nullAnnot(foo|bar) is not in the expected format \"nullAnnot( | | )\"\n", @@ -348,7 +348,7 @@ public void test316b_warn_options() { }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot -warn:+null,syntacticAnalysis -proc:none -d \"" + OUTPUT_DIR + "\"", "", "", @@ -381,7 +381,7 @@ public void test313_warn_options() { }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot -warn:-null -proc:none -d \"" + OUTPUT_DIR + "\"", "", "----------\n" + @@ -432,7 +432,7 @@ public void test320_warn_options() { }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "Sub.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -err:+nullAnnot,+null,+inheritNullAnnot -proc:none -d \"" + OUTPUT_DIR + "\"", "", "----------\n" + @@ -479,7 +479,7 @@ public void testBug466291() { "}" }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot(p.Nullable|p.NonNull|p.NonNullByDefault) -warn:+null -warn:-nullUncheckedConversion " + "-proc:none -d \"" + OUTPUT_DIR + "\"", "", @@ -509,7 +509,7 @@ public void testBug466291() { "\"" + OUTPUT_DIR + File.separator + "p2" + File.separator + "X2.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" + " -classpath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault)" + " -warn:+nullAnnot(p.Nullable||p.NonNullByDefault) -warn+null -proc:none -d \"" + OUTPUT_DIR + "\"", // nonnull remains unset for secondaries "", @@ -561,7 +561,7 @@ public void testBug466291b() { "}" }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot(p.Nullable|p.NonNull|p.NonNullByDefault) -warn:+null -warn:-nullUncheckedConversion " + "-proc:none -d \"" + OUTPUT_DIR + "\"", "", @@ -593,7 +593,7 @@ public void testBug466291b() { "\"" + OUTPUT_DIR + File.separator + "p2" + File.separator + "X2.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" + " -classpath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -warn:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault)" + " -warn:+nullAnnot(|x.AbsentNonNull|) " + " -warn:+nullAnnot(p.Nullable||p.NonNullByDefault) " @@ -641,7 +641,7 @@ public void testBug375366c() throws IOException { }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -properties " + OUTPUT_DIR + File.separator +".settings" + File.separator + "org.eclipse.jdt.core.prefs " + " -d \"" + OUTPUT_DIR + "\"", "", @@ -695,7 +695,7 @@ public void testBug375366d() throws IOException { }, "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\"" + " -sourcepath \"" + OUTPUT_DIR + "\"" - + " -1.5" + + " -" + CompilerOptions.getFirstSupportedJavaVersion() + " -properties " + OUTPUT_DIR + File.separator +".settings" + File.separator + "org.eclipse.jdt.core.prefs " + " -d \"" + OUTPUT_DIR + "\"", "", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java index 4c70a46b62e..7c8e86098ff 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java @@ -24,7 +24,7 @@ public PolymorphicSignatureTest(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { return PolymorphicSignatureTest.class; diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakAnnotatedTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakAnnotatedTests.java index ec95894afe5..f21c8af015d 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakAnnotatedTests.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakAnnotatedTests.java @@ -39,7 +39,7 @@ public ResourceLeakAnnotatedTests(String name) { public static Test suite() { TestSuite suite = new TestSuite(ResourceLeakAnnotatedTests.class.getName()); // argument 'inheritedDepth' is not exposed in original API, therefore these helpers are copied below with this arg added - buildMinimalComplianceTestSuite(F_1_7, 1, suite, ResourceLeakAnnotatedTests.class); + buildMinimalComplianceTestSuite(FIRST_SUPPORTED_JAVA_VERSION, 1, suite, ResourceLeakAnnotatedTests.class); return suite; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java index 4f7dbc42316..9800414da99 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java @@ -27,6 +27,7 @@ import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({ "unchecked", "rawtypes" }) public class StackMapAttributeTest extends AbstractRegressionTest { @@ -47,7 +48,7 @@ public static Class testClass() { // TESTS_RANGE = new int[] { 23 -1,}; } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_6); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public void test001() throws Exception { this.runConformTest( @@ -7145,7 +7146,6 @@ public void test055a() throws Exception { } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=366999 public void test056() throws Exception { - if (this.complianceLevel < ClassFileConstants.JDK1_7) return; this.runConformTest( new String[] { "X.java", @@ -7793,8 +7793,6 @@ public void testBug380313() throws Exception { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=380313 // Verify the generated code does not have same branch target for the 2 return statements public void testBug380313b() throws Exception { - if (this.complianceLevel < ClassFileConstants.JDK1_7) - return; this.runConformTest( new String[] { "X.java", @@ -8254,7 +8252,6 @@ public void test394718() throws Exception { // https://bugs.eclipse.org/412203 public void testBug412203_a() throws Exception { - if (this.complianceLevel < ClassFileConstants.JDK1_7) return; // using <> Map options = getCompilerOptions(); options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED); options.put(JavaCore.COMPILER_PB_NULL_REFERENCE, JavaCore.ERROR); @@ -8320,7 +8317,7 @@ public void testBug412203_a() throws Exception { "}\n", }, "", - getLibsWithNullAnnotations(ClassFileConstants.JDK1_7), + getLibsWithNullAnnotations(CompilerOptions.getFirstSupportedJdkLevel()), true/*flush*/, null/*vmArgs*/, options, @@ -8442,7 +8439,7 @@ public void testBug412203_b() throws Exception { "}\n", }, "", - getLibsWithNullAnnotations(ClassFileConstants.JDK1_7), + getLibsWithNullAnnotations(CompilerOptions.getFirstSupportedJdkLevel()), true/*flush*/, null/*vmArgs*/, options, @@ -8559,7 +8556,7 @@ public void testBug412203_c() throws Exception { "}\n", }, "", - getLibsWithNullAnnotations(ClassFileConstants.JDK1_7), + getLibsWithNullAnnotations(CompilerOptions.getFirstSupportedJdkLevel()), true/*flush*/, null/*vmArgs*/, options, diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuppressWarningsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuppressWarningsTest.java index 95d6ff97a2f..e44e781757d 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuppressWarningsTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuppressWarningsTest.java @@ -25,7 +25,7 @@ public SuppressWarningsTest(String name) { } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { @@ -43,6 +43,7 @@ protected Map getCompilerOptions() { } public void testSimpleSuppressWarnings() { + String firstSupportedVersion = CompilerOptions.getFirstSupportedJavaVersion(); this.runTest(true, new String[] { "p/SuppressTest.java", @@ -56,12 +57,13 @@ public void testSimpleSuppressWarnings() { }, "\"" + OUTPUT_DIR + File.separator + "p/SuppressTest.java\"" + " -warn:+unused -warn:+boxing " - + " -1.5 -g -preserveAllLocals" + + " -" + firstSupportedVersion + " -g -preserveAllLocals" + " -d \"" + OUTPUT_DIR + "\" ", "", "", true, null); } public void testNestedSuppressWarnings() { + String firstSupportedVersion = CompilerOptions.getFirstSupportedJavaVersion(); this.runTest(true, new String[] { "p/SuppressTest.java", @@ -77,12 +79,13 @@ public void testNestedSuppressWarnings() { }, "\"" + OUTPUT_DIR + File.separator + "p/SuppressTest.java\"" + " -warn:+unused -warn:+boxing " - + " -1.5 -g -preserveAllLocals" + + " -" + firstSupportedVersion + " -g -preserveAllLocals" + " -d \"" + OUTPUT_DIR + "\" ", "", "", true, null); } public void testUnrelatedSuppressWarnings() { + String firstSupportedVersion = CompilerOptions.getFirstSupportedJavaVersion(); this.runTest(true, new String[] { "p/SuppressTest.java", @@ -97,7 +100,7 @@ public void testUnrelatedSuppressWarnings() { }, "\"" + OUTPUT_DIR + File.separator + "p/SuppressTest.java\"" + " -warn:+unused -warn:+boxing " - + " -1.5 -g -preserveAllLocals" + + " -" + firstSupportedVersion + " -g -preserveAllLocals" + " -d \"" + OUTPUT_DIR + "\" ", "", "----------\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java index 494bcc86415..b95385cea7c 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java @@ -262,49 +262,15 @@ public static Test suite() { all.addTest(new TestSuite(HashtableOfObjectTest.class)); all.addTest(new TestSuite(JrtUtilTest.class)); int possibleComplianceLevels = AbstractCompilerTest.getPossibleComplianceLevels(); - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_3) != 0) { - ArrayList tests_1_3 = (ArrayList)standardTests.clone(); - tests_1_3.add(Compliance_1_3.class); - tests_1_3.add(JavadocTest_1_3.class); - tests_1_3.add(Compliance_CLDC.class); - TestCase.resetForgottenFilters(tests_1_3); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_3, tests_1_3)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_4) != 0) { - ArrayList tests_1_4 = (ArrayList)standardTests.clone(); - tests_1_4.addAll(since_1_4); - tests_1_4.add(Compliance_1_4.class); - tests_1_4.add(ClassFileReaderTest_1_4.class); - tests_1_4.add(JavadocTest_1_4.class); - TestCase.resetForgottenFilters(tests_1_4); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_4, tests_1_4)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_5) != 0) { - ArrayList tests_1_5 = (ArrayList)standardTests.clone(); - tests_1_5.addAll(since_1_4); - tests_1_5.addAll(since_1_5); - TestCase.resetForgottenFilters(tests_1_5); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_5, tests_1_5)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_6) != 0) { - ArrayList tests_1_6 = (ArrayList)standardTests.clone(); - tests_1_6.addAll(since_1_4); - tests_1_6.addAll(since_1_5); - tests_1_6.addAll(since_1_6); - TestCase.resetForgottenFilters(tests_1_6); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_6, tests_1_6)); - } - if ((possibleComplianceLevels & AbstractCompilerTest.F_1_7) != 0) { - ArrayList tests_1_7 = (ArrayList)standardTests.clone(); - tests_1_7.addAll(since_1_4); - tests_1_7.addAll(since_1_5); - tests_1_7.addAll(since_1_6); - tests_1_7.addAll(since_1_7); - TestCase.resetForgottenFilters(tests_1_7); - all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_7, tests_1_7)); - } + if ((possibleComplianceLevels & AbstractCompilerTest.F_1_8) != 0) { ArrayList tests_1_8 = (ArrayList)standardTests.clone(); + tests_1_8.add(Compliance_1_3.class); + tests_1_8.add(JavadocTest_1_3.class); + tests_1_8.add(Compliance_CLDC.class); + tests_1_8.add(Compliance_1_4.class); + tests_1_8.add(ClassFileReaderTest_1_4.class); + tests_1_8.add(JavadocTest_1_4.class); tests_1_8.addAll(since_1_4); tests_1_8.addAll(since_1_5); tests_1_8.addAll(since_1_6); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatement17Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatement17Test.java index ffad02ae8ac..5dfa4b2fe2a 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatement17Test.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatement17Test.java @@ -29,7 +29,7 @@ public TryStatement17Test(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public void test001() { this.runNegativeTest( diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java index 6ac0148c4d0..fc7f0ad03e6 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java @@ -36,7 +36,7 @@ public TryWithResourcesStatementTest(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } // Test resource type related errors public void test001() { @@ -3153,9 +3153,9 @@ public void test048() { public void test049() { Runner runner = new Runner(); runner.customOptions = getCompilerOptions(); - runner.customOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - runner.customOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - runner.customOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + runner.customOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + runner.customOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + runner.customOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); runner.testFiles = new String[] { "X.java", @@ -3185,7 +3185,7 @@ public void test049() { " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + "Resource specification not allowed here for source level below 1.7\n" + "----------\n"; - runner.javacTestOptions = JavacTestOptions.forRelease("5"); + runner.javacTestOptions = JavacTestOptions.forRelease("8"); runner.runNegativeTest(); } public void test050() { @@ -3259,9 +3259,9 @@ public void test051() { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=348406 public void test052() { Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); this.runNegativeTest( new String[] { "X.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnderscoresInLiteralsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnderscoresInLiteralsTest.java index 098dd3fbe67..cdce580a1ff 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnderscoresInLiteralsTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnderscoresInLiteralsTest.java @@ -28,7 +28,7 @@ public UnderscoresInLiteralsTest(String name) { super(name); } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_7); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { @@ -394,9 +394,9 @@ public void test021() { } public void test022() { Map customedOptions = getCompilerOptions(); - customedOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - customedOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); - customedOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + customedOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + customedOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + customedOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); this.runNegativeTest( new String[] { "X.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/XLargeTest2.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/XLargeTest2.java index 20162535196..c650cfe4b06 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/XLargeTest2.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/XLargeTest2.java @@ -27,7 +27,7 @@ public XLargeTest2(String name) { } public static Test suite() { - return buildMinimalComplianceTestSuite(testClass(), F_1_5); + return buildMinimalComplianceTestSuite(testClass(), FIRST_SUPPORTED_JAVA_VERSION); } public static Class testClass() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java index 2678a9dbee2..75f75e8ca1c 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java @@ -35,11 +35,6 @@ @SuppressWarnings({ "unchecked", "rawtypes" }) public class AbstractCompilerTest extends TestCase { - public static final int F_1_3 = 0x01; - public static final int F_1_4 = 0x02; - public static final int F_1_5 = 0x04; - public static final int F_1_6 = 0x08; - public static final int F_1_7 = 0x10; public static final int F_1_8 = 0x20; public static final int F_9 = 0x40; public static final int F_10 = 0x80; @@ -55,6 +50,8 @@ public class AbstractCompilerTest extends TestCase { public static final int F_20 = 0x20000; public static final int F_21 = 0x40000; public static final int F_22 = 0x80000; + /** Should be adopted if {@link CompilerOptions#getFirstSupportedJdkLevel()} changes */ + public static final int FIRST_SUPPORTED_JAVA_VERSION = F_1_8; public static final boolean RUN_JAVAC = CompilerOptions.ENABLED.equals(System.getProperty("run.javac")); public static final boolean PERFORMANCE_ASSERTS = !CompilerOptions.DISABLED.equals(System.getProperty("jdt.performance.asserts")); @@ -82,11 +79,6 @@ public class AbstractCompilerTest extends TestCase { protected static boolean reflectNestedClassUseDollar; public static int[][] complianceTestLevelMapping = new int[][] { - new int[] {F_1_3, ClassFileConstants.MAJOR_VERSION_1_3}, - new int[] {F_1_4, ClassFileConstants.MAJOR_VERSION_1_4}, - new int[] {F_1_5, ClassFileConstants.MAJOR_VERSION_1_5}, - new int[] {F_1_6, ClassFileConstants.MAJOR_VERSION_1_6}, - new int[] {F_1_7, ClassFileConstants.MAJOR_VERSION_1_7}, new int[] {F_1_8, ClassFileConstants.MAJOR_VERSION_1_8}, new int[] {F_9, ClassFileConstants.MAJOR_VERSION_9}, new int[] {F_10, ClassFileConstants.MAJOR_VERSION_10}, @@ -267,16 +259,6 @@ else if (highestLevel == ClassFileConstants.JDK9) complianceString = "9"; else if (highestLevel == ClassFileConstants.JDK1_8) complianceString = "1.8"; - else if (highestLevel == ClassFileConstants.JDK1_7) - complianceString = "1.7"; - else if (highestLevel == ClassFileConstants.JDK1_6) - complianceString = "1.6"; - else if (highestLevel == ClassFileConstants.JDK1_5) - complianceString = "1.5"; - else if (highestLevel == ClassFileConstants.JDK1_4) - complianceString = "1.4"; - else if (highestLevel == ClassFileConstants.JDK1_3) - complianceString = "1.3"; else { highestLevel = ClassFileConstants.getLatestJDKLevel(); if (highestLevel > 0) { @@ -310,7 +292,7 @@ public static long highestComplianceLevels() { return ClassFileConstants.getComplianceLevelForJavaVersion(map[1]); } } - return ClassFileConstants.JDK1_3; + return CompilerOptions.getFirstSupportedJdkLevel(); } static void initReflectionVersion() { @@ -371,15 +353,9 @@ public static int getPossibleComplianceLevels() { if (compliances != null) { possibleComplianceLevels = 0; for (String compliance : compliances.split(",")) { - if (CompilerOptions.VERSION_1_3.equals(compliance)) { - possibleComplianceLevels |= RUN_JAVAC ? NONE : F_1_3; - } else if (CompilerOptions.VERSION_1_4.equals(compliance)) { - possibleComplianceLevels |= RUN_JAVAC ? NONE : F_1_4; - } boolean versionValid = false; for(int i = 0; i < complianceTestLevelMapping.length; i++) { int[] versionMap = complianceTestLevelMapping[i]; - if (versionMap[0] < F_1_5) continue; long jdkLevel = ClassFileConstants.getComplianceLevelForJavaVersion(versionMap[1]); String versionString = CompilerOptions.versionFromJdkLevel(jdkLevel); if (versionString.equals(compliance)) { @@ -391,12 +367,6 @@ public static int getPossibleComplianceLevels() { if (!versionValid) { System.out.println("Ignoring invalid compliance (" + compliance + ")"); System.out.print("Use one of "); - System.out.print(CompilerOptions.VERSION_1_3 + ", "); - System.out.print(CompilerOptions.VERSION_1_4 + ", "); - System.out.print(CompilerOptions.VERSION_1_5 + ", "); - System.out.print(CompilerOptions.VERSION_1_6 + ", "); - System.out.print(CompilerOptions.VERSION_1_7 + ", "); - System.out.print(CompilerOptions.VERSION_1_8 + ", "); System.out.print(CompilerOptions.VERSION_1_8 + ", "); System.out.print(CompilerOptions.VERSION_9 + ", "); System.out.print(CompilerOptions.VERSION_10 + ", "); @@ -421,18 +391,11 @@ public static int getPossibleComplianceLevels() { } if (possibleComplianceLevels == UNINITIALIZED) { if (!RUN_JAVAC) { - possibleComplianceLevels = F_1_3; - boolean canRunPrevious = !"1.0".equals(specVersion) - && !CompilerOptions.VERSION_1_1.equals(specVersion) - && !CompilerOptions.VERSION_1_2.equals(specVersion) - && !CompilerOptions.VERSION_1_3.equals(specVersion); - if (canRunPrevious) { - possibleComplianceLevels |= F_1_4; - } + possibleComplianceLevels = FIRST_SUPPORTED_JAVA_VERSION; + boolean canRunPrevious = true; String previousVersion = CompilerOptions.VERSION_1_4; for(int i = 0; i < complianceTestLevelMapping.length; i++) { int[] versionMap = complianceTestLevelMapping[i]; - if (versionMap[0] < F_1_5) continue; long jdkLevel = ClassFileConstants.getComplianceLevelForJavaVersion(versionMap[1]); String versionString = CompilerOptions.versionFromJdkLevel(jdkLevel); boolean canRunNext = canRunPrevious && !previousVersion.equals(specVersion); @@ -443,16 +406,9 @@ public static int getPossibleComplianceLevels() { } previousVersion = versionString; } - } else if ("1.0".equals(specVersion) - || CompilerOptions.VERSION_1_1.equals(specVersion) - || CompilerOptions.VERSION_1_2.equals(specVersion) - || CompilerOptions.VERSION_1_3.equals(specVersion) - || CompilerOptions.VERSION_1_4.equals(specVersion)) { - possibleComplianceLevels = NONE; } else { for(int i = 0; i < complianceTestLevelMapping.length; i++) { int[] versionMap = complianceTestLevelMapping[i]; - if (versionMap[0] < F_1_5) continue; long jdkLevel = ClassFileConstants.getComplianceLevelForJavaVersion(versionMap[1]); String versionString = CompilerOptions.versionFromJdkLevel(jdkLevel); if (versionString.equals(specVersion)) { @@ -474,16 +430,6 @@ public static int getPossibleComplianceLevels() { */ public static Test suite(String suiteName, Class setupClass, ArrayList testClasses) { TestSuite all = new TestSuite(suiteName); - int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels(); - if ((complianceLevels & AbstractCompilerTest.F_1_3) != 0) { - all.addTest(suiteForComplianceLevel(ClassFileConstants.JDK1_3, setupClass, testClasses)); - } - if ((complianceLevels & AbstractCompilerTest.F_1_4) != 0) { - all.addTest(suiteForComplianceLevel(ClassFileConstants.JDK1_4, setupClass, testClasses)); - } - if ((complianceLevels & AbstractCompilerTest.F_1_5) != 0) { - all.addTest(suiteForComplianceLevel(ClassFileConstants.JDK1_5, setupClass, testClasses)); - } return all; } @@ -575,27 +521,7 @@ public AbstractCompilerTest(String name) { protected Map getCompilerOptions() { Map options = new CompilerOptions().getMap(); options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE); - if (this.complianceLevel == ClassFileConstants.JDK1_3) { - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1); - } else if (this.complianceLevel == ClassFileConstants.JDK1_4) { - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); - } else if (this.complianceLevel == ClassFileConstants.JDK1_5) { - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - } else if (this.complianceLevel == ClassFileConstants.JDK1_6) { - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); - } else if (this.complianceLevel == ClassFileConstants.JDK1_7) { - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); - } else if (this.complianceLevel == ClassFileConstants.JDK1_8) { + if (this.complianceLevel == ClassFileConstants.JDK1_8) { options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8); options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8); options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8); diff --git a/org.eclipse.jdt.core.tests.compiler/test.xml b/org.eclipse.jdt.core.tests.compiler/test.xml index 5d62db0411c..b787c2eecfa 100644 --- a/org.eclipse.jdt.core.tests.compiler/test.xml +++ b/org.eclipse.jdt.core.tests.compiler/test.xml @@ -57,7 +57,7 @@ diff --git a/org.eclipse.jdt.core.tests.model/pom.xml b/org.eclipse.jdt.core.tests.model/pom.xml index 5e3c9463a85..2c483c4671d 100644 --- a/org.eclipse.jdt.core.tests.model/pom.xml +++ b/org.eclipse.jdt.core.tests.model/pom.xml @@ -88,7 +88,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,14,17 + --add-modules ALL-SYSTEM -Dcompliance=1.8,14,17 @@ -109,7 +109,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,15,18 + --add-modules ALL-SYSTEM -Dcompliance=1.8,15,18 @@ -130,7 +130,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,17,19 + --add-modules ALL-SYSTEM -Dcompliance=1.8,17,19 @@ -151,7 +151,7 @@ - --add-modules ALL-SYSTEM -Dcompliance=1.4,1.8,17,19,21 + --add-modules ALL-SYSTEM -Dcompliance=1.8,17,19,21 diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java index bc05d803ad9..60feea222e1 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java @@ -2596,11 +2596,6 @@ protected String[] getJCL15PlusLibraryIfNeeded(String compliance) throws JavaMod setUpJCLClasspathVariables("1.8"); return new String[] {getExternalJCLPathString("1.8")}; } - if (compliance.charAt(compliance.length()-1) >= '5' && (AbstractCompilerTest.getPossibleComplianceLevels() & AbstractCompilerTest.F_1_5) != 0) { - // ensure that the JCL 15 lib is setup (i.e. that the jclMin15.jar is copied) - setUpJCLClasspathVariables("1.5"); - return new String[] {getExternalJCLPathString("1.5")}; - } return null; } /** diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java index 2a048b0d2d5..4595ff74b42 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java @@ -336,13 +336,12 @@ public final class JavaCore extends Plugin { /** * Compiler option ID: Defining Target Java Platform. *

For binary compatibility reasons, .class files are tagged with a minimal required VM version.

- *

Note that "1.4" and higher target versions require the compliance mode to be at least as high + *

Note that "1.8" and higher target versions require the compliance mode to be at least as high * as the target version. Usually, compliance, target, and source versions are set to the same values.

- *

"cldc1.1" requires the source version to be "1.3" and the compliance version to be "1.4" or lower.

*
*
Option id:
"org.eclipse.jdt.core.compiler.codegen.targetPlatform"
- *
Possible values:
{ "1.1", "cldc1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9", "10", "11" }
- *
Default:
"1.2"
+ *
Possible values:
{ "1.8", "9", ..., {@link #latestSupportedJavaVersion()} }
+ *
Default:
"1.8"
*
* @category CompilerOptionID * @see #COMPILER_COMPLIANCE @@ -2222,8 +2221,8 @@ public final class JavaCore extends Plugin { * set to the same version as the source level.

*
*
Option id:
"org.eclipse.jdt.core.compiler.source"
- *
Possible values:
{ "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9", "10", "11" }
- *
Default:
"1.3"
+ *
Possible values:
{ "1.8", "9", ..., {@link #latestSupportedJavaVersion()} }
+ *
Default:
"1.8"
*
* @since 2.0 * @category CompilerOptionID @@ -2240,8 +2239,8 @@ public final class JavaCore extends Plugin { * should match the compliance setting.

*
*
Option id:
"org.eclipse.jdt.core.compiler.compliance"
- *
Possible values:
{ "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9", "10", "11" }
- *
Default:
"1.4"
+ *
Possible values:
{ "1.8", "9", ..., {@link #latestSupportedJavaVersion()} }
+ *
Default:
"1.8"
*
* @since 2.0 * @category CompilerOptionID @@ -6389,44 +6388,6 @@ public static void setComplianceOptions(String compliance, Map options) { long jdkLevel = CompilerOptions.versionToJdkLevel(compliance); int major = (int) (jdkLevel >>> 16); switch(major) { - case ClassFileConstants.MAJOR_VERSION_1_3: - options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3); - options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); - options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1); - options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.IGNORE); - options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE); - break; - case ClassFileConstants.MAJOR_VERSION_1_4: - options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); - options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); - options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); - options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING); - options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING); - break; - case ClassFileConstants.MAJOR_VERSION_1_5: - options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); - options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); - options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); - options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); - options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); - options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); - break; - case ClassFileConstants.MAJOR_VERSION_1_6: - options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6); - options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6); - options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6); - options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); - options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); - options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); - break; - case ClassFileConstants.MAJOR_VERSION_1_7: - options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); - options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); - options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7); - options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); - options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); - options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); - break; case ClassFileConstants.MAJOR_VERSION_1_8: options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); From e54f26a9da22f89e7adae32951eed62cc3239807 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Wed, 17 Jul 2024 13:55:20 +0200 Subject: [PATCH 2/4] Test adaptation for unsupported Java versions The tests were updated to compile with at least Java 1.8 and against Java 1.8 jcl library. See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2536 --- .../src/java/lang/StringBuilder.java | 164 + .../META-INF/MANIFEST.MF | 2 +- .../jdt/apt/pluggable/tests/TestBase.java | 3 +- .../META-INF/MANIFEST.MF | 2 +- org.eclipse.jdt.apt.tests/pom.xml | 2 +- .../eclipse/jdt/apt/tests/APTTestBase.java | 3 +- .../AnnotationProcessingCompilerToolTest.java | 5 +- .../tests/AnnotationValueConversionTests.java | 3 +- .../jdt/apt/tests/AptBuilderTests.java | 3 +- .../jdt/apt/tests/AptReconcileTests.java | 5 +- .../jdt/apt/tests/JavaVersionTests.java | 94 - .../eclipse/jdt/apt/tests/MirrorTests.java | 3 +- .../org/eclipse/jdt/apt/tests/PerfTests.java | 3 +- .../jdt/apt/tests/PreferencesTests.java | 7 +- .../jdt/apt/tests/ReadAnnotationTests2.java | 3 +- .../jdt/apt/tests/RegressionTests.java | 13 +- .../eclipse/jdt/apt/tests/ScalingTests.java | 3 +- .../jdt/apt/tests/StarProcessorTests.java | 3 +- .../org/eclipse/jdt/apt/tests/TestAll.java | 1 - .../tool/tests/CompilerInvocationTests.java | 5 +- .../tool/tests/CompilerToolTests.java | 16 +- .../META-INF/MANIFEST.MF | 158 +- .../compiler/tool/EclipseFileManager.java | 1 + .../tests/builder/AbstractMethodTests.java | 13 +- .../builder/AnnotationDependencyTests.java | 3 +- .../core/tests/builder/BasicBuildTests.java | 3 +- .../jdt/core/tests/builder/Bug549457Test.java | 27 +- .../jdt/core/tests/builder/BuilderTests.java | 19 +- .../core/tests/builder/BuilderTests11.java | 10 - .../core/tests/builder/BuildpathTests.java | 35 +- .../core/tests/builder/DependencyTests.java | 3 - .../core/tests/builder/GetResourcesTests.java | 172 +- .../core/tests/builder/IncrementalTests.java | 15 +- .../jdt/core/tests/builder/Java50Tests.java | 19 +- .../core/tests/builder/LeakTestsBefore9.java | 2 +- .../core/tests/builder/MultiProjectTests.java | 15 +- .../core/tests/builder/PackageInfoTest.java | 39 +- .../tests/builder/ParticipantBuildTests.java | 19 +- .../AnnotationCompletionParserTest.java | 6 +- .../parser/AnnotationDietRecoveryTest.java | 1 - .../parser/EnumCompletionParserTest.java | 6 +- .../compiler/parser/EnumDietRecoveryTest.java | 11 +- .../parser/GenericDietRecoveryTest.java | 12 +- .../parser/GenericsCompletionParserTest.java | 6 +- .../parser/JavadocCompletionParserTest.java | 2 +- .../tests/compiler/parser/ParserTest1_7.java | 6 +- .../parser/SourceElementParserTest.java | 6 +- .../parser/StatementRecoveryTest_1_5.java | 6 +- .../regression/AbstractBatchCompilerTest.java | 36 +- .../regression/AbstractComparableTest.java | 8 +- .../compiler/regression/AnnotationTest.java | 52 +- .../tests/compiler/regression/ArrayTest.java | 54 +- .../regression/BatchCompilerTest.java | 982 ++---- .../regression/BatchCompilerTest2.java | 12 +- .../regression/BinaryLiteralTest.java | 46 +- .../regression/ClassFileComparatorTest.java | 21 - .../regression/ClassFileReaderTest_1_4.java | 90 +- .../regression/CompilerInvocationTests.java | 27 +- .../compiler/regression/Compliance_1_3.java | 731 ++--- .../compiler/regression/Compliance_1_4.java | 285 +- .../compiler/regression/Compliance_1_7.java | 53 +- .../compiler/regression/DeprecatedTest.java | 2 +- .../compiler/regression/GenericTypeTest.java | 8 +- .../regression/GenericsRegressionTest.java | 52 +- .../GenericsRegressionTest_1_7.java | 61 +- .../compiler/regression/JavadocTest_1_3.java | 2640 +---------------- .../compiler/regression/JavadocTest_1_4.java | 2620 +--------------- .../tests/compiler/regression/Jsr14Test.java | 49 +- .../tests/compiler/regression/LookupTest.java | 65 +- .../compiler/regression/MethodVerifyTest.java | 320 +- .../ResourceLeakAnnotatedTests.java | 14 +- .../compiler/regression/ScannerTest.java | 97 +- .../TryWithResourcesStatementTest.java | 72 +- .../regression/UnderscoresInLiteralsTest.java | 2 +- .../compiler/regression/Unicode18Test.java | 58 - .../compiler/regression/VarargsTest.java | 19 +- .../tests/dom/StandAloneASTParserTest.java | 4 +- .../core/tests/eval/DebugEvaluationTest.java | 10 +- .../eval/EvaluationContextWrapperTest.java | 17 +- .../eclipse/jdt/core/tests/eval/TestAll.java | 1 + .../core/tests/util/AbstractCompilerTest.java | 2 +- .../org/eclipse/jdt/core/tests/util/Util.java | 9 + .../JCL/converterJclMin1.8.jar | Bin 41866 -> 42793 bytes .../JCL/converterJclMin1.8src.zip | Bin 55181 -> 55716 bytes .../tests/dom/ASTConverter15JLS4Test.java | 103 +- .../tests/dom/ASTConverter15JLS8Test.java | 86 +- .../core/tests/dom/ASTConverter15Test.java | 108 +- .../core/tests/dom/ASTConverterAST3Test.java | 9 +- .../core/tests/dom/ASTConverterAST4Test.java | 9 +- .../core/tests/dom/ASTConverterAST8Test.java | 9 +- .../tests/dom/ASTConverterBugsTestJLS3.java | 6 +- .../tests/dom/ASTConverterJavadocTest.java | 7 +- .../tests/dom/ASTConverterRecoveryTest.java | 10 +- .../jdt/core/tests/dom/ASTConverterTest.java | 16 +- .../jdt/core/tests/dom/ASTConverterTest2.java | 48 +- .../tests/dom/ASTConverterTestAST3_2.java | 54 +- .../tests/dom/ASTConverterTestAST4_2.java | 92 +- .../tests/dom/ASTConverterTestAST8_2.java | 57 +- .../core/tests/dom/ASTConverter_15Test.java | 2 +- .../core/tests/dom/ASTModelBridgeTests.java | 37 +- .../jdt/core/tests/dom/AbstractASTTests.java | 6 +- .../core/tests/dom/BatchASTCreationTests.java | 23 +- .../tests/dom/CompatibilityRulesTests.java | 24 +- .../core/tests/dom/ConverterTestSetup.java | 44 +- .../tests/dom/ProfilingASTConvertionTest.java | 7 +- .../tests/formatter/FormatterBugsTests.java | 2 +- .../formatter/FormatterCommentsTests.java | 8 +- .../formatter/FormatterRegressionTests.java | 888 +++--- .../tests/model/AbstractJavaModelTests.java | 132 +- .../AbstractJavadocCompletionModelTest.java | 6 +- .../tests/model/AccessRestrictionsTests.java | 111 +- .../core/tests/model/AttachSourceTests.java | 12 +- .../tests/model/AttachedJavadocTests.java | 15 +- .../jdt/core/tests/model/BufferTests.java | 5 +- .../jdt/core/tests/model/Bug376673Test.java | 5 +- .../jdt/core/tests/model/ClassFileTests.java | 11 +- .../jdt/core/tests/model/ClassNameTests.java | 11 +- .../model/ClasspathInitializerTests.java | 9 +- .../jdt/core/tests/model/ClasspathTests.java | 154 +- .../core/tests/model/CodeCorrectionTests.java | 7 +- .../tests/model/CompilationUnitTests.java | 9 +- .../tests/model/CompletionContextTests.java | 49 +- .../model/CompletionContextTests_1_5.java | 15 +- .../jdt/core/tests/model/CompletionTests.java | 434 ++- .../core/tests/model/CompletionTests18.java | 5 +- .../core/tests/model/CompletionTests2.java | 466 ++- .../core/tests/model/CompletionTests3.java | 61 +- .../core/tests/model/CompletionTests9.java | 4 +- .../core/tests/model/CompletionTests_1_5.java | 31 +- .../CompletionWithMissingTypesTests.java | 13 +- .../CompletionWithMissingTypesTests2.java | 65 +- .../CompletionWithMissingTypesTests_1_5.java | 9 +- .../CompletionWithMissingTypesTests_1_8.java | 5 +- .../tests/model/CopyMoveElementsTests.java | 5 +- .../tests/model/CopyMoveResourcesTests.java | 7 +- .../core/tests/model/CreateImportsTests.java | 7 +- .../jdt/core/tests/model/DeleteTests.java | 5 +- .../jdt/core/tests/model/ExistenceTests.java | 9 +- .../model/ExternalAnnotations17Test.java | 63 +- .../model/ExternalAnnotations18Test.java | 9 +- .../jdt/core/tests/model/GetSourceTests.java | 5 +- .../model/HierarchyOnWorkingCopiesTests.java | 7 +- ...ptionalProblemsFromSourceFoldersTests.java | 12 +- .../tests/model/InclusionPatternsTests.java | 3 +- .../core/tests/model/IndexManagerTests.java | 3 +- .../core/tests/model/JavaConventionTests.java | 93 +- .../tests/model/JavaCoreOptionsTests.java | 9 +- .../tests/model/JavaElementDeltaTests.java | 2 +- .../core/tests/model/JavaProjectTests.java | 118 +- .../tests/model/JavaSearchBugs16Tests.java | 5 +- .../tests/model/JavaSearchBugs17Tests.java | 8 +- .../tests/model/JavaSearchBugs8Tests.java | 2 +- .../core/tests/model/JavaSearchBugsTests.java | 244 +- .../tests/model/JavaSearchBugsTests2.java | 157 +- .../JavaSearchMultipleProjectsTests.java | 51 +- .../tests/model/JavaSearchScopeTests.java | 4 +- .../jdt/core/tests/model/JavaSearchTests.java | 25 +- .../model/JavadocBugsCompletionModelTest.java | 47 +- .../model/JavadocCompletionContextTests.java | 10 +- .../JavadocCompletionContextTests_1_5.java | 10 +- .../JavadocFieldCompletionModelTest.java | 39 +- .../JavadocMethodCompletionModelTest.java | 122 +- .../JavadocPackageCompletionModelTest.java | 11 +- .../model/JavadocTextCompletionModelTest.java | 60 +- .../model/JavadocTypeCompletionModelTest.java | 82 +- .../core/tests/model/LocalElementTests.java | 3 +- .../jdt/core/tests/model/MementoTests.java | 5 +- .../jdt/core/tests/model/ModelTestsUtil.java | 16 - .../core/tests/model/ModuleBuilderTests.java | 86 +- .../core/tests/model/NameLookupTests2.java | 7 +- .../tests/model/NamingConventionTests.java | 19 +- .../tests/model/NullAnnotationModelTests.java | 118 +- .../jdt/core/tests/model/OptionTests.java | 50 +- .../tests/model/OverflowingCacheTests.java | 2 +- .../ReconcilerStatementsRecoveryTests.java | 11 +- .../jdt/core/tests/model/ReconcilerTests.java | 745 +---- .../jdt/core/tests/model/RenameTests.java | 7 +- .../jdt/core/tests/model/ResolveTests.java | 16 +- .../jdt/core/tests/model/ResolveTests2.java | 54 +- .../core/tests/model/ResolveTests_1_5.java | 23 +- .../jdt/core/tests/model/SearchTests.java | 119 +- .../model/SelectionJavadocModelTests.java | 31 +- .../model/SnippetCompletionContextTests.java | 9 +- .../model/SnippetCompletionTests_1_5.java | 6 +- .../SortCompilationUnitElementsTests.java | 5 +- .../tests/model/SubstringCompletionTests.java | 17 +- .../tests/model/SubwordCompletionTests.java | 15 - .../model/TypeHierarchyNotificationTests.java | 13 +- .../core/tests/model/TypeHierarchyTests.java | 124 +- .../core/tests/model/TypeResolveTests.java | 55 +- .../model/WorkingCopyNotInClasspathTests.java | 3 +- .../tests/model/WorkingCopyOwnerTests.java | 2 +- .../tests/model/WorkingCopySearchTests.java | 1 + .../ASTRewritingExpressionsTest.java | 89 - .../ASTRewritingStatementsTest.java | 36 +- .../rewrite/describing/ASTRewritingTest.java | 56 +- .../describing/ASTRewritingTypeDeclTest.java | 469 --- .../rewrite/describing/ImportRewriteTest.java | 9 +- .../describing/ImportRewrite_RecordTest.java | 2 +- .../modifying/ASTRewritingModifyingTest.java | 20 +- .../workspace/AccessRestrictions/.classpath | 2 +- .../workspace/AttachSourceTests/.classpath | 2 +- .../AttachedJavadocProject/.classpath | 2 +- .../workspace/CodeCorrection/.classpath | 2 +- .../workspace/Completion/.classpath | 2 +- .../Converter/src/javadoc/test000/Test.java | 1 - .../src/javadoc/testBug54424/Test.java | 2 +- .../workspace/Converter15/.classpath | 2 +- .../workspace/Converter16/.classpath | 2 +- .../workspace/Converter17/.classpath | 2 +- .../workspace/Converter_15_1/.classpath | 2 +- .../workspace/CreateMembers/.classpath | 2 +- .../workspace/Encoding/.classpath | 2 +- .../ExternalAnnotations17/Test1/.classpath | 2 +- .../workspace/ExternalContainer/.classpath | 2 +- .../workspace/Formatter/.classpath | 2 +- .../workspace/FormatterBugs/.classpath | 2 +- .../workspace/FormatterJavadoc/.classpath | 2 +- .../JavaModelManagerTests/.classpath | 2 +- .../workspace/JavaProjectSrcTests/.classpath | 2 +- .../workspace/JavaProjectTests/.classpath | 2 +- .../workspace/JavaSearch/.classpath | 2 +- .../workspace/JavaSearch15/.classpath | 2 +- .../workspace/JavaSearchBugs/.classpath | 2 +- .../JavaSearchMultipleProjects1/.classpath | 2 +- .../JavaSearchMultipleProjects2/.classpath | 2 +- .../workspace/Resolve/.classpath | 2 +- .../workspace/Resolve15/.classpath | 2 +- .../workspace/SnippetCompletion/.classpath | 2 +- .../workspace/Tests/.classpath | 2 +- .../workspace/TypeHierarchy/.classpath | 2 +- .../TypeHierarchyDependent/.classpath | 2 +- .../TypeHierarchyNotification/.classpath | 2 +- .../TypeHierarchySerialization/.classpath | 2 +- .../workspace/TypeResolve/.classpath | 2 +- .../performance/FullSourceWorkspaceTests.java | 22 +- .../jdt/core/dom/CompilationUnitResolver.java | 3 +- 237 files changed, 4511 insertions(+), 11836 deletions(-) create mode 100644 JCL/converterJclMin1.8/src/java/lang/StringBuilder.java delete mode 100644 org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/JavaVersionTests.java diff --git a/JCL/converterJclMin1.8/src/java/lang/StringBuilder.java b/JCL/converterJclMin1.8/src/java/lang/StringBuilder.java new file mode 100644 index 00000000000..813d94976a9 --- /dev/null +++ b/JCL/converterJclMin1.8/src/java/lang/StringBuilder.java @@ -0,0 +1,164 @@ +package java.lang; + + +public final class StringBuilder { + + public StringBuilder() { + } + + public StringBuilder(int capacity) { + } + + public StringBuilder(String str) { + } + + public StringBuilder(CharSequence seq) { + } + + public StringBuilder append(Object obj) { + return this; + } + + public StringBuilder append(String str) { + return this; + } + + public StringBuilder append(StringBuffer sb) { + return this; + } + + public StringBuilder append(CharSequence s) { + return this; + } + + public StringBuilder append(CharSequence s, int start, int end) { + return this; + } + + public StringBuilder append(char[] str) { + return this; + } + + public StringBuilder append(char[] str, int offset, int len) { + return this; + } + + public StringBuilder append(boolean b) { + return this; + } + + public StringBuilder append(char c) { + return this; + } + + + public StringBuilder append(int i) { + return this; + } + + + public StringBuilder append(long lng) { + return this; + } + + + public StringBuilder append(float f) { + return this; + } + + + public StringBuilder append(double d) { + return this; + } + + public StringBuilder appendCodePoint(int codePoint) { + return this; + } + + public StringBuilder delete(int start, int end) { + return this; + } + + public StringBuilder deleteCharAt(int index) { + return this; + } + + public StringBuilder replace(int start, int end, String str) { + return this; + } + + public StringBuilder insert(int index, char[] str, int offset, int len) { + return this; + } + + public StringBuilder insert(int offset, Object obj) { + return this; + } + + public StringBuilder insert(int offset, String str) { + return this; + } + + public StringBuilder insert(int offset, char[] str) { + return this; + } + + public StringBuilder insert(int dstOffset, CharSequence s) { + return this; + } + + public StringBuilder insert(int dstOffset, CharSequence s, int start, int end) { + return this; + } + + public StringBuilder insert(int offset, boolean b) { + return this; + } + + public StringBuilder insert(int offset, char c) { + return this; + } + + + public StringBuilder insert(int offset, int i) { + return this; + } + + public StringBuilder insert(int offset, long l) { + return this; + } + + public StringBuilder insert(int offset, float f) { + return this; + } + + public StringBuilder insert(int offset, double d) { + return this; + } + + public int indexOf(String str) { + return 0; + } + + public int indexOf(String str, int fromIndex) { + return 0; + } + + public int lastIndexOf(String str) { + return 0; + } + + public int lastIndexOf(String str, int fromIndex) { + return 0; + } + + public StringBuilder reverse() { + return this; + } + + public String toString() { + return ""; + } + + +} diff --git a/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF index ada8f22e8e9..eb20fc68430 100644 --- a/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF @@ -13,7 +13,7 @@ Require-Bundle: org.junit, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.compiler, org.eclipse.test.performance, - org.eclipse.jdt.core;bundle-version="3.36.0", + org.eclipse.jdt.core;bundle-version="3.38.0", org.eclipse.ui.ide, org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)";resolution:=optional, org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestBase.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestBase.java index 3c256d7a621..7ab5f45a164 100644 --- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestBase.java +++ b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestBase.java @@ -41,7 +41,6 @@ public class TestBase extends BuilderTests { - protected static final String JAVA_16_COMPLIANCE = "1.6"; protected static final String JAVA_18_COMPLIANCE = "1.8"; protected static final String JAVA_9_COMPLIANCE = "9"; @@ -91,7 +90,7 @@ private static void addAnnotationJar(IJavaProject jproj, boolean addToModulePath */ protected static IJavaProject createJavaProject(final String projectName) throws Exception { - IPath projectPath = env.addProject(projectName, JAVA_16_COMPLIANCE); + IPath projectPath = env.addProject(projectName, JAVA_18_COMPLIANCE); env.addExternalJars(projectPath, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF index 3a602c29d64..fe19775beab 100644 --- a/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.apt.tests; singleton:=true -Bundle-Version: 3.6.400.qualifier +Bundle-Version: 3.6.500.qualifier Bundle-ClassPath: apt.jar, aptext.jar, . diff --git a/org.eclipse.jdt.apt.tests/pom.xml b/org.eclipse.jdt.apt.tests/pom.xml index 47b08fae5c2..54fdeb21263 100644 --- a/org.eclipse.jdt.apt.tests/pom.xml +++ b/org.eclipse.jdt.apt.tests/pom.xml @@ -19,7 +19,7 @@ ../tests-pom/ org.eclipse.jdt.apt.tests - 3.6.400-SNAPSHOT + 3.6.500-SNAPSHOT eclipse-test-plugin diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APTTestBase.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APTTestBase.java index 5e3a022d36e..a0b0f9336dd 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APTTestBase.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APTTestBase.java @@ -33,6 +33,7 @@ import org.eclipse.jdt.core.tests.builder.BuilderTests; import org.eclipse.jdt.core.tests.builder.Problem; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import com.sun.mirror.apt.AnnotationProcessor; @@ -96,7 +97,7 @@ protected IJavaProject getCurrentJavaProject() { protected IJavaProject createJavaProject(final String projectName ) throws Exception { - IPath projectPath = env.addProject( projectName, "1.5" ); + IPath projectPath = env.addProject( projectName, CompilerOptions.getFirstSupportedJavaVersion() ); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationProcessingCompilerToolTest.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationProcessingCompilerToolTest.java index ceef38a6445..175e7410336 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationProcessingCompilerToolTest.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationProcessingCompilerToolTest.java @@ -32,6 +32,7 @@ import javax.tools.ToolProvider; import org.eclipse.jdt.core.tests.compiler.regression.AbstractBatchCompilerTest; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.tool.EclipseCompiler; import junit.framework.Test; @@ -77,7 +78,7 @@ public void test_github844() throws IOException { null /* standardJavaFileManager */, Arrays.asList( "-d", OUTPUT_DIR, - "-source", "1.6", + "-source", CompilerOptions.getFirstSupportedJavaVersion(), "-g", "-preserveAllLocals", "-cp", OUTPUT_DIR + File.pathSeparator + _extJar.getAbsolutePath() , "-s", OUTPUT_DIR + File.separator + "src-gen", @@ -161,7 +162,7 @@ public class Works2 { null /* standardJavaFileManager */, Arrays.asList( "-d", OUTPUT_DIR, - "-source", "1.6", + "-source", CompilerOptions.getFirstSupportedJavaVersion(), "-g", "-preserveAllLocals", "-cp", OUTPUT_DIR + File.pathSeparator + _extJar.getAbsolutePath() , "-s", OUTPUT_DIR + File.separator + "src-gen", diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueConversionTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueConversionTests.java index ce3dc379358..a30ef1ccdec 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueConversionTests.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueConversionTests.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class AnnotationValueConversionTests extends APTTestBase { @@ -67,7 +68,7 @@ private IProject setupTest() throws Exception { ProcessorTestStatus.reset(); // project will be deleted by super-class's tearDown() method - IPath projectPath = env.addProject( getUniqueProjectName(), "1.5" ); //$NON-NLS-1$ + IPath projectPath = env.addProject( getUniqueProjectName(), CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$ env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ env.addExternalJars( projectPath, Util.getJavaClassLibs() ); fullBuild( projectPath ); diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java index b510cb5821b..5ccdb63cfea 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java @@ -30,6 +30,7 @@ import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class AptBuilderTests extends APTTestBase { @@ -53,7 +54,7 @@ public void setUp() throws Exception // project will be deleted by super-class's tearDown() method // create a project with a src directory as the project root directory // - IPath projectPath = env.addProject( getProjectName_ProjectRootAsSrcDir(), "1.5" ); + IPath projectPath = env.addProject( getProjectName_ProjectRootAsSrcDir(), CompilerOptions.getFirstSupportedJavaVersion() ); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); fullBuild( projectPath ); diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java index 003e3a9ee90..c46833db230 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java @@ -29,6 +29,7 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.WorkingCopyOwner; import org.eclipse.jdt.core.tests.model.ModifyingResourceTests; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class AptReconcileTests extends ModifyingResourceTests { @@ -490,8 +491,8 @@ public void setUp() throws Exception this._problemRequestor = new ProblemRequestor(); final IJavaProject project = createJavaProject( _testProject, - new String[] { "src" }, new String[] { "JCL15_LIB" }, - "bin", "1.5" ); + new String[] { "src" }, new String[] { "JCL18_LIB" }, + "bin", CompilerOptions.getFirstSupportedJavaVersion() ); TestUtil.createAndAddAnnotationJar(project); AptConfig.setEnabled(project, true); diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/JavaVersionTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/JavaVersionTests.java deleted file mode 100644 index 80f763018f1..00000000000 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/JavaVersionTests.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 BEA Systems, Inc. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * jgarms@bea.com - initial API and implementation - * - *******************************************************************************/ - -package org.eclipse.jdt.apt.tests; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus; -import org.eclipse.jdt.apt.tests.annotations.mirrortest.CodeExample; -import org.eclipse.jdt.core.tests.builder.BuilderTests; -import org.eclipse.jdt.core.tests.util.Util; - -/** - * Test that processors do not get invoked on pre-1.5 projects - */ -public class JavaVersionTests extends BuilderTests { - - public JavaVersionTests(final String name) { - super( name ); - } - - public static Test suite() { - return new TestSuite( JavaVersionTests.class ); - } - - public void setUp() throws Exception { - super.setUp(); - - // project will be deleted by super-class's tearDown() method - IPath projectPath = env.addProject( getProjectName(), "1.4" ); //$NON-NLS-1$ - env.addExternalJars( projectPath, Util.getJavaClassLibs() ); - fullBuild( projectPath ); - - // remove old package fragment root so that names don't collide - env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$ - - env.addPackageFragmentRoot( projectPath, "src" ); //$NON-NLS-1$ - env.setOutputFolder( projectPath, "bin" ); //$NON-NLS-1$ - - TestUtil.createAndAddAnnotationJar( env - .getJavaProject( projectPath ) ); - } - - public static String getProjectName() { - return JavaVersionTests.class.getName() + "Project"; //$NON-NLS-1$ - } - - public IPath getSourcePath() { - IProject project = env.getProject( getProjectName() ); - IFolder srcFolder = project.getFolder( "src" ); //$NON-NLS-1$ - IPath srcRoot = srcFolder.getFullPath(); - return srcRoot; - } - - /** - * Runs the MirrorTestAnnotationProcessor, which contains - * the actual tests - */ - public void testMirror() throws Exception { - ProcessorTestStatus.reset(); - - IProject project = env.getProject( getProjectName() ); - IPath srcRoot = getSourcePath(); - - String code = CodeExample.CODE; - - env.addClass( - srcRoot, - CodeExample.CODE_PACKAGE, - CodeExample.CODE_CLASS_NAME, - code ); - - fullBuild( project.getFullPath() ); - - assertFalse("Processor was run", ProcessorTestStatus.processorRan()); //$NON-NLS-1$ - } - -} diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java index cc74657628f..ffcc16e3b95 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java @@ -26,6 +26,7 @@ import org.eclipse.jdt.apt.tests.annotations.mirrortest.CodeExample; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class MirrorTests extends APTTestBase { @@ -66,7 +67,7 @@ public void testMirror() throws Exception { public void testTypeParmaterAPI() throws Exception{ final String projName = MirrorTests.class.getName() + "TypeParameter.Project"; //$NON-NLS-1$ - IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$ + IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$ env.addExternalJars( projectPath, Util.getJavaClassLibs() ); env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PerfTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PerfTests.java index c06a63684a7..95f1aafe978 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PerfTests.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PerfTests.java @@ -37,6 +37,7 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.tests.builder.BuilderTests; import org.eclipse.jdt.core.tests.builder.Problem; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import junit.framework.Test; import junit.framework.TestSuite; @@ -75,7 +76,7 @@ public void setUp() throws Exception } // project will be deleted by super-class's tearDown() method - projectPath = env.addProject( "org.eclipse.jdt.core", "1.4" ); //$NON-NLS-1$ //$NON-NLS-2$ + projectPath = env.addProject( "org.eclipse.jdt.core", CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$ //$NON-NLS-2$ System.out.println("Performing full build..."); //$NON-NLS-1$ fullBuild( projectPath ); diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PreferencesTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PreferencesTests.java index e31dbff9954..6eafb932f79 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PreferencesTests.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PreferencesTests.java @@ -39,6 +39,7 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class PreferencesTests extends APTTestBase { @@ -220,10 +221,10 @@ public void testAutomaticOptions() throws Exception { assertTrue(sourcepath.length() > 0); String target = options.get("-target"); - assertEquals(target, "1.5"); + assertEquals(target, CompilerOptions.getFirstSupportedJavaVersion()); String source = options.get("-source"); - assertEquals(source, "1.5"); + assertEquals(source, CompilerOptions.getFirstSupportedJavaVersion()); String bindir = options.get("-d"); assertNotNull(bindir); @@ -264,7 +265,7 @@ public void testGenSrcDir() throws Exception { public void testConfigGenSrcDir() throws Exception { final String projectName = "ConfigTestProj"; - IPath projectPath = env.addProject( projectName, "1.5" ); + IPath projectPath = env.addProject( projectName, CompilerOptions.getFirstSupportedJavaVersion() ); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); final IJavaProject javaProj = env.getJavaProject(projectName); // APT is not enabled diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java index c258fdf4a67..2c3ec1b7210 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java @@ -38,6 +38,7 @@ import org.eclipse.jdt.core.dom.IVariableBinding; import org.eclipse.jdt.core.tests.builder.BuilderTests; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; /** * This test the dom layer of annotation support. No APT involved. @@ -138,7 +139,7 @@ private void addAllSources() private IProject setupTest() throws Exception { // project will be deleted by super-class's tearDown() method - IPath projectPath = env.addProject( getUniqueProjectName(), "1.5" ); //$NON-NLS-1$ + IPath projectPath = env.addProject( getUniqueProjectName(), CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$ env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ env.addExternalJars( projectPath, Util.getJavaClassLibs() ); diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/RegressionTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/RegressionTests.java index ca55e037111..fba3598711d 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/RegressionTests.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/RegressionTests.java @@ -28,6 +28,7 @@ import org.eclipse.jdt.apt.core.util.IFactoryPath; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class RegressionTests extends APTTestBase { @@ -53,7 +54,7 @@ public void testBugzilla104032() throws Exception { // set up project with unique name final String projName = RegressionTests.class.getName() + "104032.Project"; //$NON-NLS-1$ - IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$ + IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$ @@ -99,7 +100,7 @@ public void testBugzilla104032() throws Exception public void testBugzilla106541() throws Exception { final String projName = RegressionTests.class.getName() + "104032.Project"; //$NON-NLS-1$ - IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$ + IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$ @@ -131,7 +132,7 @@ public void testBugzilla106541() throws Exception // doesn't work because of a jdt.core type system universe problem. public void testBugzilla120255() throws Exception{ final String projName = RegressionTests.class.getName() + "120255.Project"; //$NON-NLS-1$ - IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$ + IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$ @@ -175,7 +176,7 @@ public void testBugzilla120255() throws Exception{ */ public void testBugzilla206591A() throws Exception { final String projName = RegressionTests.class.getName() + "206591.Project"; //$NON-NLS-1$ - IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$ + IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$ @@ -244,7 +245,7 @@ public void testBugzilla206591A() throws Exception { */ public void testBugzilla206591B() throws Exception { final String projName = RegressionTests.class.getName() + "206591.Project"; //$NON-NLS-1$ - IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$ + IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$ @@ -298,7 +299,7 @@ public void testBugzilla206591B() throws Exception { public void testBugzilla423254() throws Exception { final String projName = RegressionTests.class.getName() + "423254.Project"; //$NON-NLS-1$ - IPath projectPath = env.addProject(projName, "1.5"); //$NON-NLS-1$ + IPath projectPath = env.addProject(projName, CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScalingTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScalingTests.java index 56be81408cf..3273db85046 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScalingTests.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScalingTests.java @@ -26,6 +26,7 @@ import org.eclipse.jdt.apt.core.util.AptConfig; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; /** * @@ -61,7 +62,7 @@ public void testGeneratingLotsOfFiles() throws Exception // set up project with unique name final String projName = ScalingTests.class.getName() + "LotsOfFilesProject"; //$NON-NLS-1$ - IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$ + IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/StarProcessorTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/StarProcessorTests.java index b3786a439e3..9c376d74161 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/StarProcessorTests.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/StarProcessorTests.java @@ -31,6 +31,7 @@ import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; /** * Tests for processors that return '*' from getSupportedAnnotations @@ -57,7 +58,7 @@ public void setUp() throws Exception // project will be deleted by super-class's tearDown() method // create a project with a src directory as the project root directory // - IPath projectPath = env.addProject( getProjectName_ProjectRootAsSrcDir(), "1.5" ); + IPath projectPath = env.addProject( getProjectName_ProjectRootAsSrcDir(), CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars( projectPath, Util.getJavaClassLibs() ); fullBuild( projectPath ); diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java index 55d16f45062..ec7135c29fb 100644 --- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java @@ -54,7 +54,6 @@ public static Test suite() suite.addTest(MirrorDeclarationTests.suite()); suite.addTest(MirrorUtilTests.suite()); suite.addTest(AnnotationValueConversionTests.suite()); - suite.addTest(JavaVersionTests.suite()); suite.addTest(RegressionTests.suite()); suite.addTest(FileGenerationTests.suite()); suite.addTest(MixedModeTesting.suite()); diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java index b59aa6efae5..ea1b38fff9b 100644 --- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java +++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java @@ -41,7 +41,6 @@ import javax.tools.StandardLocation; import org.eclipse.jdt.internal.compiler.batch.Main; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @@ -82,7 +81,7 @@ protected void checkClassFiles(String[] fileNames) { fail("IO exception for file " + fileNames[i]); } assertNotNull("Could not read " + fileNames[i], reader); - assertEquals("Wrong Java version for " + fileNames[i], ClassFileConstants.JDK1_8, reader.getVersion()); + assertEquals("Wrong Java version for " + fileNames[i], CompilerOptions.getFirstSupportedJdkLevel(), reader.getVersion()); } } void runTest( @@ -97,7 +96,7 @@ void runTest( String[] classFileNames) { List opt = options == null ? new ArrayList<>() : new ArrayList<>(options); opt.add("-source"); - opt.add("1.8"); + opt.add(CompilerOptions.getFirstSupportedJavaVersion()); super.runTest( shouldCompileOK, sourceFiles, diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java index 8c4cbe4d6ba..ed00972b240 100644 --- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java +++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java @@ -53,6 +53,7 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.tool.EclipseCompiler; import junit.framework.TestCase; @@ -85,20 +86,9 @@ public CompilerToolTests(String name) { "-classNames" }; static final String[] ZERO_ARG_OPTIONS = { - "-1.3", - "-1.4", - "-1.5", - "-1.6", - "-1.7", "-1.8", "-8", "-8.0", - "-7", - "-7.0", - "-6", - "-6.0", - "-5", - "-5.0", "-deprecation", "-nowarn", "-warn:none", @@ -528,7 +518,7 @@ public JavaFileObject getJavaFileForOutput(Location location, List options = new ArrayList<>(); options.add("-d"); options.add(tmpFolder); - options.add("-1.5"); + options.add("-" + CompilerOptions.getFirstSupportedJavaVersion()); CompilationTask task = compiler.getTask(printWriter, forwardingJavaFileManager, null, options, null, units); // check the classpath location assertTrue("Has no location CLASS_OUPUT", forwardingJavaFileManager.hasLocation(StandardLocation.CLASS_OUTPUT)); @@ -550,7 +540,7 @@ public JavaFileObject getJavaFileForOutput(Location location, assertTrue("Should not happen", false); } assertNotNull("No reader", reader); - assertEquals("Not a 1.5 .class file", ClassFileConstants.JDK1_5, reader.getVersion()); + assertEquals("Not a 1.8 .class file", ClassFileConstants.JDK1_8, reader.getVersion()); stringWriter = new StringWriter(); printWriter = new PrintWriter(stringWriter); diff --git a/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF index fde7acdde60..c32ea5e326a 100644 --- a/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF @@ -12,21 +12,143 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17 Export-Package: META-INF.services, org.eclipse.jdt.core.compiler, org.eclipse.jdt.core.compiler.batch, - org.eclipse.jdt.internal.antadapter;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests, org.eclipse.jdt.apt.pluggable.core", - org.eclipse.jdt.internal.compiler.apt.dispatch;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler.apt.model;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler.apt.util;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler.ast;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests, org.eclipse.jdt.apt.pluggable.core", - org.eclipse.jdt.internal.compiler.batch;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler.classfmt;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests, org.eclipse.jdt.apt.pluggable.core", - org.eclipse.jdt.internal.compiler.codegen;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler.env;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests, org.eclipse.jdt.apt.pluggable.core", - org.eclipse.jdt.internal.compiler.flow;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler.impl;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests, org.eclipse.jdt.apt.pluggable.core", - org.eclipse.jdt.internal.compiler.lookup;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests, org.eclipse.jdt.apt.pluggable.core", - org.eclipse.jdt.internal.compiler.parser;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler.parser.diagnose;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler.problem;x-friends:="org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests, org.eclipse.jdt.apt.pluggable.core", - org.eclipse.jdt.internal.compiler.tool;x-friends:="org.eclipse.jdt.compiler.tool.tests,org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests", - org.eclipse.jdt.internal.compiler.util;x-friends:="org.eclipse.jdt.core.internal.tools,org.eclipse.jdt.core, org.eclipse.jdt.core.tests.model, org.eclipse.jdt.core.tests.compiler, org.eclipse.jdt.core.tests.builder, org.eclipse.jdt.core.tests.performance, org.eclipse.jdt.ui.tests, org.eclipse.jdt.apt.core" + org.eclipse.jdt.internal.antadapter; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests, + org.eclipse.jdt.apt.pluggable.core", + org.eclipse.jdt.internal.compiler.apt.dispatch; + x-friends:="org.eclipse.jdt.apt.pluggable.core, + org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler.apt.model; + x-friends:="org.eclipse.jdt.apt.pluggable.core, + org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler.apt.util; + x-friends:="org.eclipse.jdt.apt.pluggable.core, + org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler.ast; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests, + org.eclipse.jdt.apt.pluggable.core", + org.eclipse.jdt.internal.compiler.batch; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler.classfmt; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests, + org.eclipse.jdt.apt.pluggable.core", + org.eclipse.jdt.internal.compiler.codegen; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler.env; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests, + org.eclipse.jdt.apt.pluggable.core", + org.eclipse.jdt.internal.compiler.flow; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler.impl; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests, + org.eclipse.jdt.apt.pluggable.core, + org.eclipse.jdt.apt.tests", + org.eclipse.jdt.internal.compiler.lookup; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests, + org.eclipse.jdt.apt.pluggable.core", + org.eclipse.jdt.internal.compiler.parser; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler.parser.diagnose; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler.problem; + x-friends:="org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests, + org.eclipse.jdt.apt.pluggable.core", + org.eclipse.jdt.internal.compiler.tool; + x-friends:="org.eclipse.jdt.compiler.tool.tests, + org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests", + org.eclipse.jdt.internal.compiler.util; + x-friends:="org.eclipse.jdt.core.internal.tools, + org.eclipse.jdt.core, + org.eclipse.jdt.core.tests.model, + org.eclipse.jdt.core.tests.compiler, + org.eclipse.jdt.core.tests.builder, + org.eclipse.jdt.core.tests.performance, + org.eclipse.jdt.ui.tests, + org.eclipse.jdt.apt.core" 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/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java index 2610aa75d8c..8b9ae5ba9c7 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java @@ -25,7 +25,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IRegion; @@ -37,6 +36,7 @@ import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.core.util.IClassFileReader; import org.eclipse.jdt.core.util.IMethodInfo; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({"rawtypes", "unchecked"}) public class AbstractMethodTests extends BuilderTests { @@ -163,7 +163,7 @@ public void test002() throws JavaModelException { //---------------------------- IPath project1Path = env.addProject("Project1"); //$NON-NLS-1$ env.addExternalJars(project1Path, Util.getJavaClassLibs()); - env.getJavaProject(project1Path).setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1); // need default abstract method + env.getJavaProject(project1Path).setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.getFirstSupportedJavaVersion()); // need default abstract method // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(project1Path, ""); //$NON-NLS-1$ @@ -241,7 +241,7 @@ public void test002() throws JavaModelException { /** * Check behavior in 1.1 target mode (generated default abstract method) */ - public void test003() throws JavaModelException { + public void test003() throws Exception { //---------------------------- // Step 1 //---------------------------- @@ -250,7 +250,7 @@ public void test003() throws JavaModelException { //---------------------------- IPath project1Path = env.addProject("Project1"); //$NON-NLS-1$ env.addExternalJars(project1Path, Util.getJavaClassLibs()); - env.getJavaProject(project1Path).setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1); // need default abstract method + env.getJavaProject(project1Path).setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.getFirstSupportedJavaVersion()); // need default abstract method // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(project1Path, ""); //$NON-NLS-1$ @@ -292,8 +292,6 @@ public void test003() throws JavaModelException { try { stream = classFile.getContents(); classFileReader = ToolFactory.createDefaultClassFileReader(stream, IClassFileReader.ALL); - } catch (CoreException e) { - e.printStackTrace(); } finally { if (stream != null) { try { @@ -313,8 +311,7 @@ public void test003() throws JavaModelException { break loop; } } - assertNotNull("No method found", found); - assertTrue("Not a synthetic method", found.isSynthetic()); + assertNull("Should not find a 'foo' method", found); } private String getResourceOuput(IResource[] resources) { diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AnnotationDependencyTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AnnotationDependencyTests.java index 00d77894b75..83fb8ea4502 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AnnotationDependencyTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AnnotationDependencyTests.java @@ -31,6 +31,7 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.osgi.framework.Bundle; /** @@ -52,7 +53,7 @@ public static Test suite() { public void setUp() throws Exception { super.setUp(); - this.projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ + this.projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(this.projectPath, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java index 4763658af80..031337dc67d 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java @@ -58,6 +58,7 @@ import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.compiler.Compiler; import org.eclipse.jdt.internal.compiler.CompilerConfiguration; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.builder.AbstractImageBuilder; import org.osgi.framework.Bundle; @@ -646,7 +647,7 @@ public void testbBug386901() throws JavaModelException { } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=425420 public void testBug425420() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ // don't env.addExternalJars(projectPath, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549457Test.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549457Test.java index b54e0531d36..2f3b1c1e7a4 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549457Test.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Bug549457Test.java @@ -49,7 +49,7 @@ public static Test suite() { protected void setUp() throws Exception { super.setUp(); - this.project = env.addProject("Bug549457Test"); + this.project = env.addProject("Bug549457Test", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(this.project, Util.getJavaClassLibs()); env.removePackageFragmentRoot(this.project, ""); @@ -78,17 +78,23 @@ public void testBug549457() throws Exception { IFolder srcPackageFolder = env.getWorkspace().getRoot().getFolder(this.srcPackage); assertTrue("package in source must exist", srcPackageFolder.exists()); - env.addClass(this.src, "p", "X", "package p;\n public interface X { default void foo() { /* cause an error with Java 7 */ } }"); + env.addClass(this.src, "p", "A", "package p;\n sealed class A permits B {}; final class B extends A {}"); fullBuild(this.project); - // For this test, the default is not Java 8. If this changes, we can expect no problems here. The test cares only that the source was compiled. - expectCompileProblem(this.project, "Default methods are allowed only at source level 1.8 or above"); + // For this test, the default is not Java 17. If this changes, we can expect no problems here. The test cares only that the source was compiled. + String firstSupportedJavaVersion = CompilerOptions.getFirstSupportedJavaVersion(); + String expectedProblemMessage = "'permits' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java " + + firstSupportedJavaVersion + "," + + " Syntax error on token \"permits\", extends expected," + + " Syntax error on token \"sealed\", invalid Modifiers"; + expectCompileProblem(this.project, expectedProblemMessage); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IProject testProject = workspaceRoot.getProject("Bug549457Test"); IJavaProject javaProject = JavaCore.create(testProject); - javaProject.setOption(CompilerOptions.OPTION_Compliance, "1.8"); - javaProject.setOption(CompilerOptions.OPTION_Source, "1.8"); + javaProject.setOption(CompilerOptions.OPTION_Compliance, CompilerOptions.getLatestVersion()); + javaProject.setOption(CompilerOptions.OPTION_Source, CompilerOptions.getLatestVersion()); + javaProject.setOption(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getLatestVersion()); testProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); waitForAutoBuild(); fullBuild(this.project); @@ -96,15 +102,16 @@ public void testBug549457() throws Exception { String jdtCorePreferencesFile = JavaProject.DEFAULT_PREFERENCES_DIRNAME + IPath.SEPARATOR + JavaProject.JAVA_CORE_PREFS_FILE; IFile settingsFile = testProject.getFile(jdtCorePreferencesFile); - assertTrue("expected \"" + jdtCorePreferencesFile + "\" to exist after setting compiler compliance to Java 1.7", settingsFile.exists()); + assertTrue("expected \"" + jdtCorePreferencesFile + "\" to exist after setting compiler compliance to Java " + firstSupportedJavaVersion, settingsFile.exists()); String newContents = String.join( - CompilerOptions.OPTION_Compliance + "=1.7", - CompilerOptions.OPTION_Source + "=1.7"); + CompilerOptions.OPTION_Compliance + "=" + firstSupportedJavaVersion + "\n", + CompilerOptions.OPTION_Source + "=" + firstSupportedJavaVersion + "\n", + CompilerOptions.OPTION_TargetPlatform + "=" + firstSupportedJavaVersion + "\n"); settingsFile.setContents(newContents.getBytes(), IResource.FORCE, new NullProgressMonitor()); waitForAutoBuild(); - expectCompileProblem(this.project, "Default methods are allowed only at source level 1.8 or above"); + expectCompileProblem(this.project, expectedProblemMessage); } private void waitForAutoBuild() throws InterruptedException { diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java index c5b79bad4f0..4bd8a4c5570 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java @@ -35,6 +35,7 @@ import org.eclipse.jdt.core.tests.util.TestVerifier; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.compiler.Compiler; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import junit.framework.Test; import junit.framework.TestSuite; @@ -546,15 +547,13 @@ private static Class[] getAllTestClasses() { Bug561287Test.class, Bug562420Test.class, LeakTestsBefore9.class, + Java50Tests.class, + PackageInfoTest.class, + ParticipantBuildTests.class, + AnnotationDependencyTests.class, + Bug544921Test.class }; List> list = new ArrayList<>(Arrays.asList(classes)); - if (matchesCompliance(F_1_8)) { - list.add(Java50Tests.class); - list.add(PackageInfoTest.class); - list.add(ParticipantBuildTests.class); - list.add(AnnotationDependencyTests.class); - list.add(Bug544921Test.class); - } if (matchesCompliance(F_9)) { list.add(LeakTestsAfter9.class); list.add(Bug549646Test.class); @@ -626,7 +625,7 @@ public static Test suite() { static IPath addEmptyInternalJar(IPath projectPath, String jarName) throws IOException, JavaModelException { IProject project = env.getProject(projectPath); String jarFile = project.getLocation().append(jarName).toOSString(); - Util.createEmptyJar(jarFile, JavaCore.VERSION_1_4); + Util.createEmptyJar(jarFile, CompilerOptions.getFirstSupportedJavaVersion()); IPath jarPath = null; try (FileInputStream fis = new FileInputStream(jarFile)) { int length = fis.available(); @@ -648,7 +647,7 @@ protected static void expectCompileProblem(IPath project, String expectedProblem List expectedProblemMessages = Arrays.asList(expectedProblemMessage); assertEquals("expected compile problem not observed", - expectedProblemMessages, actualProblemMessages); + expectedProblemMessages.toString(), actualProblemMessages.toString()); } protected static void expectNoCompileProblems(IPath project) { @@ -662,6 +661,6 @@ protected static void expectNoCompileProblems(IPath project) { List expectedProblemMessages = Collections.EMPTY_LIST; assertEquals("expected no compile problems", - expectedProblemMessages, actualProblemMessages); + expectedProblemMessages.toString(), actualProblemMessages.toString()); } } diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests11.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests11.java index a72ba5afa00..3586462d05c 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests11.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests11.java @@ -40,16 +40,6 @@ public void testBuildWithRelease_1_8() throws JavaModelException, Exception { runTest(compliance); } - public void testBuildWithRelease_1_7() throws JavaModelException, Exception { - String compliance = "1.7"; - runTest(compliance); - } - - public void testBuildWithRelease_1_6() throws JavaModelException, Exception { - String compliance = "1.6"; - runTest(compliance); - } - // TODO: this test fails in 4.25 M1, probably also before. // Cannot find the class file for java.lang.Object public void XtestBuilderWithRelease_9() throws JavaModelException, Exception { diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java index 30854f39544..69fcced568e 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java @@ -367,7 +367,7 @@ public void testChangeZIPArchive1() throws Exception { "}" }, externalLib, - "1.4"); + CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.addExternalJars(projectPath, new String[] {externalLib}); @@ -395,7 +395,7 @@ public void testChangeZIPArchive1() throws Exception { "}" }, externalLib, - "1.4"); + CompilerOptions.getFirstSupportedJavaVersion()); IJavaProject p = env.getJavaProject(projectPath); p.getJavaModel().refreshExternalArchives(new IJavaElement[] {p}, null); @@ -428,7 +428,7 @@ public void testChangeZIPArchive2() throws Exception { "}" }, internalLib, - "1.4"); + CompilerOptions.getFirstSupportedJavaVersion()); env.getProject(projectPath).refreshLocal(IResource.DEPTH_INFINITE, null); env.addEntry(projectPath, JavaCore.newLibraryEntry(new Path("/Project/internalLib.abc"), null, null)); @@ -460,7 +460,7 @@ public void testChangeZIPArchive2() throws Exception { "}" }, internalLib, - "1.4"); + CompilerOptions.getFirstSupportedJavaVersion()); env.getProject(projectPath).refreshLocal(IResource.DEPTH_INFINITE, null); @@ -992,6 +992,33 @@ public void testMissingOptionalProject() throws JavaModelException { env.removeProject(project2Path); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=160132 +public void test0100() throws JavaModelException { + IPath projectPath = env.addProject("P", CompilerOptions.getFirstSupportedJavaVersion()); + IPath defaultPackagePath = env.addPackage(projectPath, ""); + env.addExternalJars(projectPath, Util.getJavaClassLibs()); + env.addClass(defaultPackagePath, "X", + "public interface X {\n" + + " interface Entry {\n" + + " interface Internal extends Entry {\n" + + " Internal createEntry();\n" + + " }\n" + + " }\n" + + "}" + ); + fullBuild(); + expectingNoProblems(); + env.addClass(defaultPackagePath, "Y", + "public class Y implements X.Entry.Internal {\n" + + " public Internal createEntry() {\n" + + " return null;\n" + + " }\n" + + "}"); + incrementalBuild(); + expectingNoProblems(); + env.removeProject(projectPath); +} + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=143025 public void testMissingOutputFolder() throws JavaModelException { IPath projectPath = env.addProject("P"); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java index 11612630ca6..1afd8bec1fc 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/DependencyTests.java @@ -20,7 +20,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CategorizedProblem; -import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @@ -1150,8 +1149,6 @@ public void testTypeVisibility2() throws JavaModelException { } public void testTypeVariable() throws JavaModelException { - if ((AbstractCompilerTest.getPossibleComplianceLevels() & AbstractCompilerTest.FIRST_SUPPORTED_JAVA_VERSION) == 0) return; - IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/GetResourcesTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/GetResourcesTests.java index 9ddf18f728c..4d96d4921cb 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/GetResourcesTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/GetResourcesTests.java @@ -385,176 +385,8 @@ public void test005() throws JavaModelException { "/Project/bin/a/Anon$6.class\n" + "/Project/bin/a/Anon$7.class\n" + "/Project/bin/a/Anon$8.class\n" + - "/Project/bin/a/Anon$9.class\n" + - "/Project/bin/a/Anon$10.class\n" + - "/Project/bin/a/Anon$11.class\n" + - "/Project/bin/a/Anon$12.class\n" + - "/Project/bin/a/Anon$13.class\n" + - "/Project/bin/a/Anon$14.class\n" + - "/Project/bin/a/Anon$15.class\n" + - "/Project/bin/a/Anon$16.class\n" + - "/Project/bin/a/Anon$Anon2.class\n"; - assertEquals("Wrong names", Util.convertToIndependantLineDelimiter(expectedOutput), actualOutput); - env.removeProject(projectPath); - } - - //https://bugs.eclipse.org/bugs/show_bug.cgi?id=6584 - public void test006() throws JavaModelException { - IPath projectPath = null; - try { - projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ - } catch (RuntimeException e) { - // no 1.5 VM or above is available - return; - } - env.addExternalJars(projectPath, Util.getJavaClassLibs()); - fullBuild(projectPath); - - // remove old package fragment root so that names don't collide - env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ - - IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ - env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ - - env.addClass(root, "a", "Anon", //$NON-NLS-1$ //$NON-NLS-2$ - "package a;\n" + - "\n" + - "public class Anon {\n" + - "\n" + - " Anon() {\n" + - " Object o1 = new Object() {\n" + - " public String toString() {\n" + - " return \"1\"; // a/Anon$3 in 1.5, a/Anon$11 in 1.4\n" + - " }\n" + - " };\n" + - " Object o2 = new Object() {\n" + - " public String toString() {\n" + - " return \"2\"; // a/Anon$4 in 1.5, a/Anon$12 in 1.4\n" + - " }\n" + - " };\n" + - " }\n" + - "\n" + - " void hello() {\n" + - " Object o3 = new Object() {\n" + - " public String toString() {\n" + - " return \"3\"; // a/Anon$5 in 1.5, a/Anon$13 in 1.4\n" + - " }\n" + - " };\n" + - " Object o4 = new Object() {\n" + - " public String toString() {\n" + - " return \"4\"; // a/Anon$6 in 1.5, a/Anon$14 in 1.4\n" + - " }\n" + - " };\n" + - " }\n" + - "\n" + - " static void hello2() {\n" + - " Object o5 = new Object() {\n" + - " public String toString() {\n" + - " return \"5\"; // a/Anon$7 in 1.5, a/Anon$15 in 1.4\n" + - " }\n" + - " };\n" + - " Object o6 = new Object() {\n" + - " public String toString() {\n" + - " return \"6\"; // a/Anon$8 in 1.5, a/Anon$16 in 1.4\n" + - " }\n" + - " };\n" + - " }\n" + - "\n" + - " static {\n" + - " Object o7 = new Object() {\n" + - " public String toString() {\n" + - " return \"7\"; // a/Anon$1 in 1.5, a/Anon$1 in 1.4\n" + - " }\n" + - " };\n" + - "\n" + - " Object o8 = new Object() {\n" + - " public String toString() {\n" + - " return \"8\"; // a/Anon$2 in 1.5, a/Anon$2 in 1.4\n" + - " }\n" + - " };\n" + - " }\n" + - "\n" + - " static class Anon2 {\n" + - " // it\'s an object init block which has different prio as constructor!\n" + - " {\n" + - " Object o1 = new Object() {\n" + - " public String toString() {\n" + - " return \"1\"; // a/Anon$Anon2$1 in 1.5, a/Anon$3 in 1.4\n" + - " }\n" + - " };\n" + - " Object o2 = new Object() {\n" + - " public String toString() {\n" + - " return \"2\"; // a/Anon$Anon2$2 in 1.5, a/Anon$4 in 1.4\n" + - " }\n" + - " };\n" + - " }\n" + - "\n" + - " void hello() {\n" + - " Object o3 = new Object() {\n" + - " public String toString() {\n" + - " return \"3\"; // a/Anon$Anon2$5 in 1.5, a/Anon$7 in 1.4\n" + - " }\n" + - " };\n" + - " Object o4 = new Object() {\n" + - " public String toString() {\n" + - " return \"4\"; // a/Anon$Anon2$6 in 1.5, a/Anon$8 in 1.4\n" + - " }\n" + - " };\n" + - " }\n" + - "\n" + - " static void hello2() {\n" + - " Object o5 = new Object() {\n" + - " public String toString() {\n" + - " return \"5\"; // a/Anon$Anon2$7 in 1.5, a/Anon$9 in 1.4\n" + - " }\n" + - " };\n" + - " Object o6 = new Object() {\n" + - " public String toString() {\n" + - " return \"6\"; // a/Anon$Anon2$8 in 1.5, a/Anon$10 in 1.4\n" + - " }\n" + - " };\n" + - " }\n" + - "\n" + - " static {\n" + - " Object o7 = new Object() {\n" + - " public String toString() {\n" + - " return \"7\"; // a/Anon$Anon2$3 in 1.5, a/Anon$5 in 1.4\n" + - " }\n" + - " };\n" + - "\n" + - " Object o8 = new Object() {\n" + - " public String toString() {\n" + - " return \"8\"; // a/Anon$Anon2$4 in 1.5, a/Anon$6 in 1.4\n" + - " }\n" + - " };\n" + - " }\n" + - " }\n" + - "}"); - - incrementalBuild(projectPath); - - IJavaProject project = env.getJavaProject(projectPath); - IPackageFragmentRoot root2 = project.getPackageFragmentRoot(project.getProject().getWorkspace().getRoot().findMember(root.makeAbsolute())); - IPackageFragment packageFragment = root2.getPackageFragment("a");//$NON-NLS-1$ - ICompilationUnit compilationUnit = packageFragment.getCompilationUnit("Anon.java");//$NON-NLS-1$ - IRegion region = JavaCore.newRegion(); - region.add(compilationUnit); - IResource[] resources = JavaCore.getGeneratedResources(region, false); - assertEquals("Wrong size", 18, resources.length);//$NON-NLS-1$ - Arrays.sort(resources, COMPARATOR); - String actualOutput = getResourceOuput(resources); - String expectedOutput = - "/Project/bin/a/Anon.class\n" + - "/Project/bin/a/Anon$1.class\n" + - "/Project/bin/a/Anon$2.class\n" + - "/Project/bin/a/Anon$3.class\n" + - "/Project/bin/a/Anon$4.class\n" + - "/Project/bin/a/Anon$5.class\n" + - "/Project/bin/a/Anon$6.class\n" + - "/Project/bin/a/Anon$7.class\n" + - "/Project/bin/a/Anon$8.class\n" + - "/Project/bin/a/Anon$Anon2.class\n" + - "/Project/bin/a/Anon$Anon2$1.class\n" + + "/Project/bin/a/Anon$Anon2.class\n" + + "/Project/bin/a/Anon$Anon2$1.class\n" + "/Project/bin/a/Anon$Anon2$2.class\n" + "/Project/bin/a/Anon$Anon2$3.class\n" + "/Project/bin/a/Anon$Anon2$4.class\n" + diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java index 6eadea0b05a..1e728adad9d 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java @@ -27,6 +27,7 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({"rawtypes", "unchecked"}) public class IncrementalTests extends BuilderTests { @@ -607,10 +608,10 @@ public void testMemberTypeFromClassFile() throws JavaModelException { //https://bugs.eclipse.org/bugs/show_bug.cgi?id=372418 public void testMemberTypeOfOtherProject() throws JavaModelException { - IPath projectPath1 = env.addProject("Project1", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath1 = env.addProject("Project1", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath1, Util.getJavaClassLibs()); - IPath projectPath2 = env.addProject("Project2", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath2 = env.addProject("Project2", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath2, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide @@ -668,10 +669,10 @@ public void testMemberTypeOfOtherProject() throws JavaModelException { //https://bugs.eclipse.org/bugs/show_bug.cgi?id=377401 public void test$InTypeName() throws JavaModelException { - IPath projectPath1 = env.addProject("Project1", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath1 = env.addProject("Project1", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ //$NON-NLS-2$ env.addExternalJars(projectPath1, Util.getJavaClassLibs()); - IPath projectPath2 = env.addProject("Project2", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath2 = env.addProject("Project2", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ //$NON-NLS-2$ env.addExternalJars(projectPath2, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide @@ -1138,9 +1139,9 @@ public void testBug334377() throws JavaModelException { try { options = JavaCore.getOptions(); Hashtable newOptions = JavaCore.getOptions(); - newOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); - newOptions.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); - newOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); + newOptions.put(JavaCore.COMPILER_COMPLIANCE, CompilerOptions.getFirstSupportedJavaVersion()); + newOptions.put(JavaCore.COMPILER_SOURCE, CompilerOptions.getFirstSupportedJavaVersion()); + newOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.getFirstSupportedJavaVersion()); JavaCore.setOptions(newOptions); IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Java50Tests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Java50Tests.java index ab7de8b929d..c71b6caaa82 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Java50Tests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Java50Tests.java @@ -19,6 +19,7 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class Java50Tests extends BuilderTests { @@ -31,7 +32,7 @@ public static Test suite() { } public void testAnnotation() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.setOutputFolder(projectPath, ""); @@ -66,7 +67,7 @@ public void testAnnotation() throws JavaModelException { } public void testHierarchyCycle() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.setOutputFolder(projectPath, ""); @@ -86,7 +87,7 @@ public void testHierarchyCycle() throws JavaModelException { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=214237, dupe of // https://bugs.eclipse.org/bugs/show_bug.cgi?id=205235 public void testHierarchyCycleInstanceof() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.setOutputFolder(projectPath, ""); @@ -114,7 +115,7 @@ public void testHierarchyCycleInstanceof() throws JavaModelException { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=231293 public void testMissingRequiredBinaries() throws JavaModelException { - IPath p1 = env.addProject("P1", "1.5"); //$NON-NLS-1$ + IPath p1 = env.addProject("P1", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ IPath p2 = env.addProject("P2"); //$NON-NLS-1$ env.addExternalJars(p1, Util.getJavaClassLibs()); @@ -169,7 +170,7 @@ public void testMissingRequiredBinaries() throws JavaModelException { } public void testParameterizedMemberType() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.setOutputFolder(projectPath, ""); @@ -234,7 +235,7 @@ public void testParameterizedMemberType() throws JavaModelException { } public void testParameterizedType1() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.setOutputFolder(projectPath, ""); @@ -275,7 +276,7 @@ public void testParameterizedType1() throws JavaModelException { } public void testParameterizedType2() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.setOutputFolder(projectPath, ""); @@ -316,7 +317,7 @@ public void testParameterizedType2() throws JavaModelException { } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=294057 public void testHierarchyNonCycle() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.setOutputFolder(projectPath, ""); @@ -350,7 +351,7 @@ public void testHierarchyNonCycle() throws JavaModelException { } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=294057 (variation) public void testHierarchyNonCycle2() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.setOutputFolder(projectPath, ""); diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java index f3a837f3bd7..05dca1ac94b 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java @@ -28,7 +28,7 @@ public static Test suite() { } String getCompatibilityLevel() { - return CompilerOptions.VERSION_1_4; + return CompilerOptions.getFirstSupportedJavaVersion(); } @Override diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java index 2e8d7c58d7a..b77c6c2ba78 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java @@ -25,6 +25,7 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.test.OrderedTestSuite; import junit.framework.Test; @@ -1932,20 +1933,20 @@ public void test103_missing_required_binaries() throws JavaModelException { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=460993 public void test104_missing_required_binaries() throws CoreException { - IPath p0 = env.addProject("JRE17", "1.7"); + IPath p0 = env.addProject("JRE17", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(p0, Util.getJavaClassLibs()); env.removePackageFragmentRoot(p0, ""); IPath root0 = env.addPackageFragmentRoot(p0, "src"); env.setOutputFolder(p0, "bin"); - IPath p1 = env.addProject("org.eclipse.jgit", "1.7"); + IPath p1 = env.addProject("org.eclipse.jgit", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(p1, Util.getJavaClassLibs()); env.removePackageFragmentRoot(p1, ""); IPath root1 = env.addPackageFragmentRoot(p1, "src"); env.addRequiredProject(p1, p0); env.setOutputFolder(p1, "bin"); - IPath p2 = env.addProject("org.eclipse.releng.tools", "1.5"); + IPath p2 = env.addProject("org.eclipse.releng.tools", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(p2, Util.getJavaClassLibs()); env.removePackageFragmentRoot(p2, ""); IPath root2 = env.addPackageFragmentRoot(p2, "src"); @@ -2097,7 +2098,7 @@ public void test461074() throws JavaModelException { //---------------------------- // Project2 //---------------------------- - IPath p2 = env.addProject("SampleLib", "1.5"); //$NON-NLS-1$ + IPath p2 = env.addProject("SampleLib", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(p2, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(p2, ""); //$NON-NLS-1$ @@ -2122,7 +2123,7 @@ public void test461074() throws JavaModelException { //---------------------------- // Project3 //---------------------------- - IPath p3 = env.addProject("SampleTest", "1.5"); //$NON-NLS-1$ + IPath p3 = env.addProject("SampleTest", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(p3, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(p3, ""); //$NON-NLS-1$ @@ -2168,7 +2169,7 @@ public void test461074_error() throws JavaModelException { //---------------------------- // Project2 //---------------------------- - IPath p2 = env.addProject("SampleLib", "1.5"); //$NON-NLS-1$ + IPath p2 = env.addProject("SampleLib", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(p2, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(p2, ""); //$NON-NLS-1$ @@ -2193,7 +2194,7 @@ public void test461074_error() throws JavaModelException { //---------------------------- // Project3 //---------------------------- - IPath p3 = env.addProject("SampleTest", "1.5"); //$NON-NLS-1$ + IPath p3 = env.addProject("SampleTest", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(p3, Util.getJavaClassLibs()); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(p3, ""); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java index 8576b6856aa..76af70f3eef 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageInfoTest.java @@ -34,6 +34,7 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings("rawtypes") public class PackageInfoTest extends BuilderTests { @@ -52,7 +53,7 @@ public static Test suite() { return buildTestSuite(PackageInfoTest.class); } public void test001() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -95,7 +96,7 @@ public void test001() throws JavaModelException { assertSourceEquals("Different messages", expectedOutput, stringWriter.toString()); } public void test002() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -147,7 +148,7 @@ public void test002() throws JavaModelException { executeClass(projectPath, "testcase.Main", "@testcase.TestAnnotation()@testcase.TestAnnotation()", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } public void test003() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -170,7 +171,7 @@ public void test003() throws JavaModelException { // test for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=252555 : NPE // on duplicate package-info public void test004() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -209,7 +210,7 @@ public void test004() throws JavaModelException { // test for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=258145 : JME // on duplicate package-info public void test258145() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -251,7 +252,7 @@ public void test258145() throws JavaModelException { // (NPE upon creation/deletion of package-info.java in default package) public void test323785 () throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -273,7 +274,7 @@ public void test323785 () throws JavaModelException { // verify that changes to package info containing secondary types do trigger incremental build. public void test323785a () throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -301,7 +302,7 @@ public void test323785a () throws JavaModelException { // test when the package-info is added with the default annotation, the problem disappears public void testBug372012() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -358,7 +359,7 @@ public void testBug372012() throws JavaModelException { // test when the the default annotations are added to all top level types, the problem stays public void testBug372012a() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -417,7 +418,7 @@ public void testBug372012a() throws JavaModelException { // test when the the default annotations is added to only 1 top level type, the problem stays public void testBug372012b() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -475,7 +476,7 @@ public void testBug372012b() throws JavaModelException { // test when the the default annotation is removed from package-info, the problem comes back public void testBug372012c() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -551,7 +552,7 @@ public void testBug367836() throws JavaModelException { // verify that markers are created on the correct resource public void testBug374063() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -595,7 +596,7 @@ public void testBug374063() throws JavaModelException { } // 382960 public void testBug382960() throws JavaModelException, CoreException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -647,7 +648,7 @@ public void testBug382960() throws JavaModelException, CoreException { // package fragments in all source folders are removed. public void testBug525469() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); fullBuild(projectPath); @@ -710,7 +711,7 @@ public void testBug525469() throws JavaModelException { // [BUG] Syntax error, modifiers are not allowed here on a @deprecated javadoc tag in package-info.java // https://bugs.eclipse.org/bugs/show_bug.cgi?id=569780 public void testIssue803() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath src = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -736,7 +737,7 @@ public void testIssue803() throws JavaModelException { // [BUG] Syntax error, modifiers are not allowed here on a @deprecated javadoc tag in package-info.java // https://bugs.eclipse.org/bugs/show_bug.cgi?id=569780 public void testIssue803_2() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath src = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -761,7 +762,7 @@ public void testIssue803_2() throws JavaModelException { // [BUG] Syntax error, modifiers are not allowed here on a @deprecated javadoc tag in package-info.java // https://bugs.eclipse.org/bugs/show_bug.cgi?id=569780 public void testIssue803_3() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath src = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -784,7 +785,7 @@ public void testIssue803_3() throws JavaModelException { // [BUG] Syntax error, modifiers are not allowed here on a @deprecated javadoc tag in package-info.java // https://bugs.eclipse.org/bugs/show_bug.cgi?id=569780 public void testIssue803_4() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath src = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -810,7 +811,7 @@ public void testIssue803_4() throws JavaModelException { // [BUG] Syntax error, modifiers are not allowed here on a @deprecated javadoc tag in package-info.java // https://bugs.eclipse.org/bugs/show_bug.cgi?id=569780 public void testIssue803_5() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath src = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java index 51a21a8b215..bb4e9864a34 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java @@ -29,6 +29,7 @@ import org.eclipse.jdt.core.tests.builder.participants.TestCompilationParticipant2; import org.eclipse.jdt.core.tests.builder.participants.TestCompilationParticipant3; import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({"rawtypes", "unchecked"}) public class ParticipantBuildTests extends BuilderTests { @@ -154,7 +155,7 @@ public void buildStarting(BuildContext[] files, boolean isBatchBuild) { } public void testDefaultValue() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -248,7 +249,7 @@ public void processAnnotations(BuildContext[] files) { * (regression test for bug 134345 Problems from CompilationParticipants do not get cleaned up unless there are Java errors) */ public void testParticipantProblems() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); @@ -283,7 +284,7 @@ public void buildStarting(BuildContext[] files, boolean isBatch) { } public void testProcessAnnotationDeclarations() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -335,7 +336,7 @@ public void processAnnotations(BuildContext[] files) { } public void testProcessAnnotationQualifiedReferences() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -382,7 +383,7 @@ public void processAnnotations(BuildContext[] files) { * Test that a build participant can inspect the declared annotations by name */ public void testProcessAnnotationHasAnnotation() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -417,7 +418,7 @@ public void processAnnotations(BuildContext[] files) { } public void testProcessAnnotationReferences() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -703,7 +704,7 @@ public Optional postProcess(BuildContext file, ByteArrayInputStream byte } public void testResolvedMethod() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ @@ -766,7 +767,7 @@ public void processAnnotations(BuildContext[] files) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158611 // Checking the GENERATED_BY attribute public void test1001() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); @@ -796,7 +797,7 @@ public void buildStarting(BuildContext[] files, boolean isBatch) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=158611 // Checking the GENERATED_BY attribute public void test1002() throws JavaModelException { - IPath projectPath = env.addProject("Project", "1.5"); + IPath projectPath = env.addProject("Project", CompilerOptions.getFirstSupportedJavaVersion()); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationCompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationCompletionParserTest.java index ab78e158293..1caff14a6ce 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationCompletionParserTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationCompletionParserTest.java @@ -38,9 +38,9 @@ public static Test suite() { @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); return options; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java index 552e9e91756..74684811d42 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java @@ -39,7 +39,6 @@ public class AnnotationDietRecoveryTest extends AbstractCompilerTest { private static final boolean CHECK_ALL_PARSE = true; public static boolean optimizeStringLiterals = false; - public static long sourceLevel = CompilerOptions.getFirstSupportedJdkLevel(); //$NON-NLS-1$ public AnnotationDietRecoveryTest(String testName){ super(testName); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java index 8aeb08b1faa..487089a185e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java @@ -34,9 +34,9 @@ public static Test suite() { @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); return options; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumDietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumDietRecoveryTest.java index 827e1722dd8..cb0733ac82f 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumDietRecoveryTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumDietRecoveryTest.java @@ -24,7 +24,6 @@ import org.eclipse.jdt.internal.compiler.SourceElementParser; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.parser.Parser; @@ -34,21 +33,17 @@ @SuppressWarnings({ "unchecked", "rawtypes" }) public class EnumDietRecoveryTest extends AbstractCompilerTest { public static boolean optimizeStringLiterals = false; - public static long sourceLevel = ClassFileConstants.JDK1_3; //$NON-NLS-1$ public EnumDietRecoveryTest(String testName){ super(testName); } -/* - * Toggle compiler in mode -1.5 - */ @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); return options; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java index 63c5d4c4081..b28326a7888 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java @@ -26,7 +26,6 @@ import org.eclipse.jdt.internal.compiler.SourceElementParser; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.parser.Parser; @@ -36,7 +35,6 @@ @SuppressWarnings({ "unchecked", "rawtypes" }) public class GenericDietRecoveryTest extends AbstractCompilerTest { public static boolean optimizeStringLiterals = false; - public static long sourceLevel = ClassFileConstants.JDK1_3; //$NON-NLS-1$ public GenericDietRecoveryTest(String testName){ super(testName); @@ -44,15 +42,13 @@ public GenericDietRecoveryTest(String testName){ static { // TESTS_NAMES = new String[] { "test0025" }; } -/* - * Toggle compiler in mode -1.5 - */ + @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); return options; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java index 27012b3658d..26b6855c593 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java @@ -30,9 +30,9 @@ public static Test suite() { @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); return options; } public void test0001(){ diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java index 1fb91890a73..3fae8559428 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/JavadocCompletionParserTest.java @@ -351,7 +351,7 @@ public void test007() { * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=123096" */ public void test008() { - this.sourceLevel = CompilerOptions.VERSION_1_3; + this.sourceLevel = CompilerOptions.getFirstSupportedJavaVersion(); String source = "package javadoc;\n" + "/**\n" + " * Completion on empty tag name:\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java index 7293067d43e..fa56093a9c1 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java @@ -236,9 +236,9 @@ public void checkParse( @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); return options; } public void test0001() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java index fdbebe98480..ea146e1a7a6 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java @@ -5346,9 +5346,9 @@ public void _test80() { public void test81() { Map options = getCompilerOptions(); - options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); - options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); - options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + options.put(JavaCore.COMPILER_SOURCE, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(JavaCore.COMPILER_COMPLIANCE, CompilerOptions.getFirstSupportedJavaVersion()); String s = "import java.util.Collection;\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java index 333be591673..aa9c14af65f 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java @@ -234,9 +234,9 @@ public void checkParse( @Override protected Map getCompilerOptions() { Map options = super.getCompilerOptions(); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); return options; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java index 383c50b4111..a1f1c1e1fd3 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java @@ -22,13 +22,13 @@ import java.io.StringReader; import java.util.ArrayList; -import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.compiler.CompilationProgress; import org.eclipse.jdt.core.compiler.batch.BatchCompiler; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.compiler.batch.ClasspathLocation; import org.eclipse.jdt.internal.compiler.batch.FileSystem; import org.eclipse.jdt.internal.compiler.batch.Main; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public abstract class AbstractBatchCompilerTest extends AbstractRegressionTest { @@ -184,7 +184,7 @@ protected void createCascadedJars() { "}", }, LIB_DIR + "/lib1.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/B.java", @@ -204,7 +204,7 @@ protected void createCascadedJars() { "}", }, LIB_DIR + "/lib2.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/C.java", @@ -224,7 +224,7 @@ protected void createCascadedJars() { "Class-Path: lib4.jar\n", }, LIB_DIR + "/lib3.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/D.java", @@ -239,7 +239,7 @@ protected void createCascadedJars() { "Class-Path: lib1.jar lib3.jar\n", }, LIB_DIR + "/lib4.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/C.java", @@ -259,7 +259,7 @@ protected void createCascadedJars() { "Class-Path: s/lib6.jar\n", }, LIB_DIR + "/lib5.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); new File(LIB_DIR + "/s").mkdir(); Util.createJar( new String[] { @@ -275,7 +275,7 @@ protected void createCascadedJars() { "Class-Path: ../lib7.jar\n", }, LIB_DIR + "/s/lib6.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/A.java", @@ -290,7 +290,7 @@ protected void createCascadedJars() { "Class-Path: lib2.jar\n", }, LIB_DIR + "/lib7.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/F.java", @@ -305,7 +305,7 @@ protected void createCascadedJars() { "Class-Path: " + LIB_DIR + "/lib3.jar lib1.jar\n", }, LIB_DIR + "/lib8.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/G.java", @@ -321,7 +321,7 @@ protected void createCascadedJars() { "Class-Path: lib3.jar\n", }, LIB_DIR + "/lib9.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/A.java", @@ -337,7 +337,7 @@ protected void createCascadedJars() { "Class-Path: lib2.jar\n", }, LIB_DIR + "/lib10.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/A.java", @@ -352,7 +352,7 @@ protected void createCascadedJars() { "Class-Path:\n", }, LIB_DIR + "/lib11.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( null, new String[] { @@ -362,7 +362,7 @@ protected void createCascadedJars() { "Class-Path:lib1.jar\n", // missing space }, LIB_DIR + "/lib12.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( null, new String[] { @@ -372,7 +372,7 @@ protected void createCascadedJars() { "Class-Path:lib1.jar lib1.jar\n", // missing space }, LIB_DIR + "/lib13.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( null, new String[] { @@ -382,7 +382,7 @@ protected void createCascadedJars() { " Class-Path: lib1.jar\n", // extra space at line start }, LIB_DIR + "/lib14.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( null, new String[] { @@ -392,7 +392,7 @@ protected void createCascadedJars() { "Class-Path: lib1.jar", // missing newline at end }, LIB_DIR + "/lib15.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); Util.createJar( new String[] { "p/A.java", @@ -412,7 +412,7 @@ protected void createCascadedJars() { "}", }, LIB_DIR + "/lib16.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); new File(LIB_DIR + "/dir").mkdir(); Util.createJar( new String[] { @@ -428,7 +428,7 @@ protected void createCascadedJars() { "Class-Path: ../lib2.jar\n", }, LIB_DIR + "/dir/lib17.jar", - JavaCore.VERSION_1_4); + CompilerOptions.getFirstSupportedJavaVersion()); CASCADED_JARS_CREATED = true; } catch (IOException e) { // ignore diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java index 4865570baf2..eeb34632cd2 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java @@ -20,11 +20,11 @@ package org.eclipse.jdt.core.tests.compiler.regression; import java.util.Map; -import junit.framework.Test; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import junit.framework.Test; + @SuppressWarnings({ "unchecked", "rawtypes" }) public class AbstractComparableTest extends AbstractRegressionTest { @@ -145,8 +145,6 @@ protected String intersection(String... types) { types = temp; } } - if (this.complianceLevel >= ClassFileConstants.JDK1_8) - return String.join(" & ", types); - return String.join("&", types); + return String.join(" & ", types); } } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java index ffe8ed0767d..7470b3d02d0 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java @@ -9134,9 +9134,9 @@ public void test272() throws Exception { return; } Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); this.runConformTest( new String[] { "X.java", @@ -11015,9 +11015,9 @@ public void test398657() throws Exception { return; } Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); this.runConformTest( new String[] { "p/Annot.java", @@ -11053,9 +11053,9 @@ public void test398657_2() throws Exception { return; } Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); this.runConformTest( new String[] { "p/Y.java", @@ -11200,13 +11200,11 @@ public void test416107b() { } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=427367 public void test427367() throws Exception { - if (this.complianceLevel < ClassFileConstants.JDK1_5) { - return; - } + Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); this.runNegativeTest( new String[] { "X.java", @@ -11264,9 +11262,7 @@ public void test427367() throws Exception { } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=376977 public void test376977() throws Exception { - if (this.complianceLevel < ClassFileConstants.JDK1_5) { - return; - } + this.runNegativeTest( new String[] { "X.java", @@ -11366,9 +11362,7 @@ public void test438437() { } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=434556, Broken class file generated for incorrect annotation usage public void test434556() throws Exception { - if (this.complianceLevel < ClassFileConstants.JDK1_5) { - return; - } + this.runNegativeTest( new String[] { "A.java", @@ -11419,9 +11413,6 @@ public void test434556() throws Exception { } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=433747, [compiler] TYPE Annotation allowed in package-info instead of only PACKAGE public void test433747() throws Exception { - if (this.complianceLevel < ClassFileConstants.JDK1_5) { - return; - } String[] src = new String[] { "p/package-info.java", "@PackageAnnot(\"p123456\")\n" + @@ -11455,13 +11446,10 @@ public void test433747() throws Exception { } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=456960 - Broken classfile generated for incorrect annotation usage - case 2 public void test456960() throws Exception { - if (this.complianceLevel < ClassFileConstants.JDK1_5) { - return; - } Map options = getCompilerOptions(); - options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.getFirstSupportedJavaVersion()); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.getFirstSupportedJavaVersion()); this.runNegativeTest( new String[] { "X.java", @@ -12351,9 +12339,7 @@ public void testBug490698_comment16() { } public void testBugVisibility() { - if (this.complianceLevel < ClassFileConstants.JDK1_5) { - return; - } + runConformTest( new String[] { "X.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java index b3b528bdd87..7a4618f3518 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java @@ -23,8 +23,6 @@ import org.eclipse.jdt.core.ToolFactory; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; -import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @SuppressWarnings({ "unchecked", "rawtypes" }) public class ArrayTest extends AbstractRegressionTest { @@ -247,10 +245,6 @@ public void test010() { } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=148807 - variation public void test011() throws Exception { - if (new CompilerOptions(getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_5) { - // there is a bug on 1.4 VMs which make them fail verification (see 148807) - return; - } this.runConformTest( new String[] { "X.java", @@ -311,10 +305,6 @@ public void test011() throws Exception { } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=148807 - variation public void test012() throws Exception { - if (new CompilerOptions(getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_5) { - // there is a bug on 1.4 VMs which make them fail verification (see 148807) - return; - } this.runConformTest( new String[] { "X.java", @@ -403,16 +393,10 @@ public void test013() { "argument cannot be resolved to a variable\n" + "----------\n"); } -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 // Check return type of array#clone() public void test014() throws Exception { Map optionsMap = getCompilerOptions(); - CompilerOptions options = new CompilerOptions(optionsMap); - if (options.complianceLevel > ClassFileConstants.JDK1_4) { - // check that #clone() return type is changed ONLY from -source 1.5 only (independant from compliance level) - optionsMap.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); - } - this.runNegativeTest( + this.runConformTest( new String[] { "X.java", "public class X {\n" + @@ -421,22 +405,12 @@ public void test014() throws Exception { " }\n" + "}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " long[] other = longs.clone();\n" + - " ^^^^^^^^^^^^^\n" + - "Type mismatch: cannot convert from Object to long[]\n" + - "----------\n", - null, - true, + "", optionsMap); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation //Check return type of array#clone() public void test015() throws Exception { - if ( new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_5) { - return; - } this.runConformTest( new String[] { "X.java", @@ -469,18 +443,8 @@ public void test016() throws Exception { "\n", ClassFileBytesDisassembler.DETAILED); - String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel <= ClassFileConstants.JDK1_4 - ? " // Method descriptor #15 ([J)V\n" + - " // Stack: 1, Locals: 3\n" + - " void foo(long[] longs) throws java.lang.Exception;\n" + - " 0 aload_1 [longs]\n" + - " 1 invokevirtual java.lang.Object.clone() : java.lang.Object [19]\n" + - " 4 astore_2 [other]\n" + - " 5 return\n" + - " Line numbers:\n" + - " [pc: 0, line: 3]\n" + - " [pc: 5, line: 4]\n" - : " // Method descriptor #15 ([J)V\n" + + String expectedOutput = + " // Method descriptor #15 ([J)V\n" + " // Stack: 1, Locals: 3\n" + " void foo(long[] longs) throws java.lang.Exception;\n" + " 0 aload_1 [longs]\n" + @@ -501,15 +465,9 @@ public void test016() throws Exception { return; } -//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation //Check constant pool declaring class of array#clone() public void test017() throws Exception { Map optionsMap = getCompilerOptions(); - CompilerOptions options = new CompilerOptions(optionsMap); - if (options.complianceLevel > ClassFileConstants.JDK1_4) { - // check that #clone() return type is changed ONLY from -source 1.5 only (independant from compliance level) - optionsMap.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); - } this.runConformTest( new String[] { "X.java", @@ -538,7 +496,7 @@ public void test017() throws Exception { " // Stack: 1, Locals: 3\n" + " void foo(long[] longs) throws java.lang.Exception;\n" + " 0 aload_1 [longs]\n" + - " 1 invokevirtual java.lang.Object.clone() : java.lang.Object [19]\n" + + " 1 invokevirtual long[].clone() : java.lang.Object [19]\n" + " 4 astore_2 [other]\n" + " 5 return\n" + " Line numbers:\n" + @@ -556,8 +514,6 @@ public void test017() throws Exception { // https://bugs.eclipse.org/331872 - [compiler] NPE in Scope.createArrayType when attempting qualified access from type parameter public void test018() throws Exception { - if (this.complianceLevel < ClassFileConstants.JDK1_5) - return; this.runNegativeTest( new String[] { "X.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java index 686fc520375..faefa08fdf0 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java @@ -80,7 +80,7 @@ public BatchCompilerTest(String name) { } /** * This test suite only needs to be run on one compliance. - * As it includes some specific 1.5 tests, it must be used with a least a 1.5 VM + * As it includes some specific 1.8 tests, it must be used with a least a 1.8 VM * and not be duplicated in general test suite. * @see TestAll */ @@ -309,8 +309,8 @@ else if (currentChar == '\n') public void test001() { - String commandLine = "-classpath \"D:/a folder\";d:/jdk1.4/jre/lib/rt.jar -1.4 -preserveAllLocals -g -verbose d:/eclipse/workspaces/development2.0/plugins/Bar/src2/ -d d:/test"; - String expected = " <-classpath> <-1.4> <-preserveAllLocals> <-g> <-verbose> <-d> "; + String commandLine = "-classpath \"D:/a folder\";d:/jdk1.8/jre/lib/rt.jar -1.8 -preserveAllLocals -g -verbose d:/eclipse/workspaces/development2.0/plugins/Bar/src2/ -d d:/test"; + String expected = " <-classpath> <-1.8> <-preserveAllLocals> <-g> <-verbose> <-d> "; String[] args = Main.tokenize(commandLine); StringBuilder buffer = new StringBuilder(30); @@ -423,7 +423,7 @@ public void test007(){ "}" }, "\"" + OUTPUT_DIR + File.separator + "X.java\"" - + " -1.5 -g -preserveAllLocals" + + " -1.8 -g -preserveAllLocals" + " -bootclasspath " + getLibraryClassesAsQuotedString() + " -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" + " -verbose -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"", @@ -461,7 +461,7 @@ public void test008(){ "}" }, "\"" + OUTPUT_DIR + File.separator + "X.java\"" - + " -1.5 -g -preserveAllLocals" + + " -1.8 -g -preserveAllLocals" + " -bootclasspath " + getLibraryClassesAsQuotedString() + " -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"", @@ -511,7 +511,7 @@ public void test009(){ "}", }, "\"" + OUTPUT_DIR + File.separator + "X.java\"" - + " -1.5 -g -preserveAllLocals" + + " -1.8 -g -preserveAllLocals" + " -cp \"" + OUTPUT_DIR + "[+OK2" + File.pathSeparator + "~Warn" + File.pathSeparator + "-KO]\"" + " -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" @@ -556,7 +556,7 @@ public void test010(){ "}" }, "\"" + OUTPUT_DIR + File.separator + "X.java\"" - + " -1.5 -g -preserveAllLocals" + + " -1.8 -g -preserveAllLocals" + " -verbose -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"", "[parsing ---OUTPUT_DIR_PLACEHOLDER---/X.java - #1/1]\n" + @@ -582,7 +582,7 @@ public void test011_classpath(){ "}", }, "\"" + OUTPUT_DIR + File.separator + "X.java\"" - + " -1.5 -g -preserveAllLocals" + + " -1.8 -g -preserveAllLocals" + " -cp \"" + OUTPUT_DIR + "[+**/OK2;~**/Warn;-KO]" + "\"" + File.pathSeparator + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"", @@ -673,11 +673,6 @@ public void test012(){ " --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" + @@ -686,12 +681,10 @@ public void test012(){ " -13 -13.0 use 13 compliance (-source 13 -target 13)\n" + " -14 -14.0 use 14 compliance (-source 14 -target 14)\n" + getVersionOptions() + - " -source set source level: 1.3 to 1.9, 10 to "+ CompilerOptions.getLatestVersion() +"\n" + - " (or 6, 6.0, etc)\n" + - " -target set classfile target: 1.3 to 1.9, 10 to "+ CompilerOptions.getLatestVersion() +"\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 "+ CompilerOptions.getLatestVersion() +"\n" + + " (or 8, 8.0, etc)\n" + + " -target set classfile target: 1.8, 1.9, 10 to "+ CompilerOptions.getLatestVersion() +"\n" + + " (or 8, 8.0, etc)\n" + " --enable-preview enable support for preview features of the\n" + " latest Java release\n" + " \n" + @@ -734,7 +727,6 @@ public void test012(){ " -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" + @@ -771,7 +763,6 @@ public void test012(){ " -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" + @@ -1003,7 +994,7 @@ public void test013() { " Zork z;\n" + "}", }, "\"" + OUTPUT_DIR + File.separator + "X.java\"" - + " -1.5 -proceedOnError" + + " -1.8 -proceedOnError" + " -log \"" + logFileName + "\" -d \"" + OUTPUT_DIR + "\"", "", "----------\n" + @@ -1021,7 +1012,7 @@ public void test013() { "\n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -1041,15 +1032,14 @@ public void test013() { "