Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjay2018-10-29 08:37:31 +0000
committerjay2018-10-30 04:53:40 +0000
commitf05b1aa547cc1c9486db2e9f3e36eebe7677fab2 (patch)
treef05f5b118df566078ebb45e6bcd015e9329ec333
parent28455b57f164175de3b3c74e8ea0c076e28d97f9 (diff)
downloadeclipse.jdt.core-Y20181030-0940.tar.gz
eclipse.jdt.core-Y20181030-0940.tar.xz
eclipse.jdt.core-Y20181030-0940.zip
Bug 540558 - [12] Create Java 12 version and supporting code in testsY20181031-2200Y20181030-1100Y20181030-0940
Change-Id: I9509531a45aad42cc9010110d7538320182f7aaf Signed-off-by: jay <jarthana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java6
-rw-r--r--org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java6
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java17
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java43
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaCoreOptionsTests.java6
-rw-r--r--org.eclipse.jdt.core/.settings/.api_filters8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java7
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java5
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java12
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java6
10 files changed, 105 insertions, 11 deletions
diff --git a/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java b/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java
index 90c8db12c7..bb96be7f31 100644
--- a/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java
+++ b/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java
@@ -118,9 +118,9 @@ public class EclipseCompiler implements JavaCompiler {
eclipseCompiler2.fileManager = this.getStandardFileManager(someDiagnosticListener, null, null);
}
- eclipseCompiler2.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_11);
- eclipseCompiler2.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_11);
- eclipseCompiler2.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_11);
+ eclipseCompiler2.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
+ eclipseCompiler2.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
+ eclipseCompiler2.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
ArrayList<String> allOptions = new ArrayList<>();
if (options != null) {
diff --git a/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java b/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java
index 37d9e294ef..8bd79d34b0 100644
--- a/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java
+++ b/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java
@@ -1364,9 +1364,9 @@ public class EclipseFileManager implements StandardJavaFileManager {
Map<String, String> options = new HashMap<>();
// FIXME: Find a way to get the options from the EclipseCompiler and pass it to the parser.
// FIXME: need to be the latest and not hardcoded value
- options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_11);
- options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_11);
- options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_11);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_12);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_12);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_12);
CompilerOptions compilerOptions = new CompilerOptions(options);
ProblemReporter problemReporter =
new ProblemReporter(
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 3c9022a29f..426340e9af 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
@@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -294,6 +298,8 @@ static class JavacCompiler {
return JavaCore.VERSION_10;
} else if(rawVersion.startsWith("11")) {
return JavaCore.VERSION_11;
+ } else if(rawVersion.startsWith("12")) {
+ return JavaCore.VERSION_12;
} else {
throw new RuntimeException("unknown javac version: " + rawVersion);
}
@@ -404,6 +410,17 @@ static class JavacCompiler {
return 0200;
}
}
+ if (version == JavaCore.VERSION_12) {
+ if ("12".equals(rawVersion)) {
+ return 0000;
+ }
+ if ("12.0.1".equals(rawVersion)) {
+ return 0100;
+ }
+ if ("12.0.2".equals(rawVersion)) {
+ return 0200;
+ }
+ }
throw new RuntimeException("unknown raw javac version: " + rawVersion);
}
// returns 0L if everything went fine; else the lower word contains the
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 eec375388a..13a2272c68 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
@@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -43,6 +47,7 @@ public class AbstractCompilerTest extends TestCase {
public static final int F_9 = 0x40;
public static final int F_10 = 0x80;
public static final int F_11 = 0x100;
+ public static final int F_12 = 0x200;
public static final boolean RUN_JAVAC = CompilerOptions.ENABLED.equals(System.getProperty("run.javac"));
private static final int UNINITIALIZED = -1;
@@ -97,6 +102,9 @@ public class AbstractCompilerTest extends TestCase {
if ((complianceLevels & AbstractCompilerTest.F_11) != 0) {
suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_11)));
}
+ if ((complianceLevels & AbstractCompilerTest.F_12) != 0) {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12)));
+ }
}
/**
@@ -139,6 +147,9 @@ public class AbstractCompilerTest extends TestCase {
if ((complianceLevels & AbstractCompilerTest.F_11) != 0) {
suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_11)));
}
+ if ((complianceLevels & AbstractCompilerTest.F_12) != 0) {
+ suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12)));
+ }
return suite;
}
@@ -289,6 +300,14 @@ public class AbstractCompilerTest extends TestCase {
suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_11)));
}
}
+ int level12 = complianceLevels & AbstractCompilerTest.F_12;
+ if (level12 != 0) {
+ if (level12 < minimalCompliance) {
+ System.err.println("Cannot run "+evaluationTestClass.getName()+" at compliance 12!");
+ } else {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12)));
+ }
+ }
return suite;
}
@@ -322,7 +341,7 @@ public class AbstractCompilerTest extends TestCase {
else if (highestLevel == ClassFileConstants.JDK1_3)
complianceString = "1.3";
else {
- highestLevel = ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_11);
+ highestLevel = ClassFileConstants.getLatestJDKLevel();
if (highestLevel > 0) {
complianceString = CompilerOptions.versionFromJdkLevel(highestLevel);
} else {
@@ -347,6 +366,9 @@ public class AbstractCompilerTest extends TestCase {
*/
public static long highestComplianceLevels() {
int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
+ if ((complianceLevels & AbstractCompilerTest.F_12) != 0) {
+ return ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_12);
+ }
if ((complianceLevels & AbstractCompilerTest.F_11) != 0) {
return ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_11);
}
@@ -423,6 +445,8 @@ public class AbstractCompilerTest extends TestCase {
possibleComplianceLevels |= F_10;
} else if (CompilerOptions.VERSION_11.equals(compliance)) {
possibleComplianceLevels |= F_11;
+ } else if (CompilerOptions.VERSION_12.equals(compliance)) {
+ possibleComplianceLevels |= F_12;
} else {
System.out.println("Ignoring invalid compliance (" + compliance + ")");
System.out.print("Use one of ");
@@ -435,7 +459,8 @@ public class AbstractCompilerTest extends TestCase {
System.out.print(CompilerOptions.VERSION_1_8 + ", ");
System.out.print(CompilerOptions.VERSION_9 + ", ");
System.out.print(CompilerOptions.VERSION_10 + ", ");
- System.out.println(CompilerOptions.VERSION_11);
+ System.out.print(CompilerOptions.VERSION_11 + ", ");
+ System.out.println(CompilerOptions.VERSION_12);
}
}
if (possibleComplianceLevels == 0) {
@@ -481,6 +506,10 @@ public class AbstractCompilerTest extends TestCase {
if (canRun11) {
possibleComplianceLevels |= F_11;
}
+ boolean canRun12 = canRun11 && !CompilerOptions.VERSION_11.equals(specVersion);
+ if (canRun12) {
+ possibleComplianceLevels |= F_11;
+ }
} else if ("1.0".equals(specVersion)
|| CompilerOptions.VERSION_1_1.equals(specVersion)
|| CompilerOptions.VERSION_1_2.equals(specVersion)
@@ -501,6 +530,9 @@ public class AbstractCompilerTest extends TestCase {
possibleComplianceLevels |= F_10;
if (!CompilerOptions.VERSION_10.equals(specVersion)) {
possibleComplianceLevels |= F_11;
+ if (!CompilerOptions.VERSION_11.equals(specVersion)) {
+ possibleComplianceLevels |= F_12;
+ }
}
}
}
@@ -656,6 +688,8 @@ public class AbstractCompilerTest extends TestCase {
options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_10);
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_10);
} else {
+ // This is already good enough to cover versions from future
+ // (as long as versionFromJdkLevel does its job)
String ver = CompilerOptions.versionFromJdkLevel(this.complianceLevel);
options.put(CompilerOptions.OPTION_Compliance, ver);
options.put(CompilerOptions.OPTION_Source, ver);
@@ -677,6 +711,11 @@ public class AbstractCompilerTest extends TestCase {
if (compliance < ClassFileConstants.JDK9) return "version 1.8 : 52.0";
if (compliance == ClassFileConstants.JDK9) return "version 9 : 53.0";
if (compliance == ClassFileConstants.JDK10) return "version 10 : 54.0";
+ if (compliance > ClassFileConstants.JDK10) {
+ String ver = CompilerOptions.versionFromJdkLevel(compliance);
+ int major = Integer.parseInt(ver) + ClassFileConstants.MAJOR_VERSION_0;
+ return "version " + ver + " : " + major + ".0";
+ }
if (compliance >= ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_11)) return version; // keep this stmt for search for next bump up
return version;
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaCoreOptionsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaCoreOptionsTests.java
index 8240228f98..e7d00035c8 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaCoreOptionsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaCoreOptionsTests.java
@@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -120,6 +124,8 @@ public void test5() {
assertTrue(JavaCore.compareJavaVersions("9", "1.8") > 0);
assertTrue(JavaCore.compareJavaVersions("9.0.1", "9.1.2") == 0);
assertTrue(JavaCore.compareJavaVersions("9", "9.1.2") == 0);
+ assertTrue(JavaCore.compareJavaVersions("12", "11") > 0);
+ assertTrue(JavaCore.compareJavaVersions("12", "1.5") > 0);
}
}
diff --git a/org.eclipse.jdt.core/.settings/.api_filters b/org.eclipse.jdt.core/.settings/.api_filters
index e67e798741..d22c1009bf 100644
--- a/org.eclipse.jdt.core/.settings/.api_filters
+++ b/org.eclipse.jdt.core/.settings/.api_filters
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jdt.core" version="2">
+ <resource path="META-INF/MANIFEST.MF">
+ <filter id="924844039">
+ <message_arguments>
+ <message_argument value="3.16.0"/>
+ <message_argument value="3.16.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="model/org/eclipse/jdt/core/util/IClassFileReader.java" type="org.eclipse.jdt.core.util.IClassFileReader">
<filter comment="default method added for getting nest members" id="404000815">
<message_arguments>
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
index 70d4378a61..48e4112b72 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
@@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -128,9 +132,10 @@ public interface ClassFileConstants {
int MAJOR_VERSION_9 = 53;
int MAJOR_VERSION_10 = 54;
int MAJOR_VERSION_11 = 55;
+ int MAJOR_VERSION_12 = 56;
int MAJOR_VERSION_0 = 44;
- int MAJOR_LATEST_VERSION = MAJOR_VERSION_11;
+ int MAJOR_LATEST_VERSION = MAJOR_VERSION_12;
int MINOR_VERSION_0 = 0;
int MINOR_VERSION_1 = 1;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index b09fa0512b..08845d093c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -224,6 +228,7 @@ public class CompilerOptions {
public static final String VERSION_9 = "9"; //$NON-NLS-1$
public static final String VERSION_10 = "10"; //$NON-NLS-1$
public static final String VERSION_11 = "11"; //$NON-NLS-1$
+ public static final String VERSION_12 = "12"; //$NON-NLS-1$
public static final String ERROR = "error"; //$NON-NLS-1$
public static final String WARNING = "warning"; //$NON-NLS-1$
public static final String INFO = "info"; //$NON-NLS-1$
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 37f5bd0f1e..df16101adb 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
@@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -3029,12 +3033,18 @@ public final class JavaCore extends Plugin {
public static final String VERSION_11 = "11"; //$NON-NLS-1$
/**
* Configurable option value: {@value}.
+ * @since 3.16
+ * @category OptionValue
+ */
+ public static final String VERSION_12 = "12"; //$NON-NLS-1$
+ /**
+ * Configurable option value: {@value}.
* @since 3.4
* @category OptionValue
*/
public static final String VERSION_CLDC_1_1 = "cldc1.1"; //$NON-NLS-1$
private static List<String> allVersions = Arrays.asList(VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5,
- VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11);
+ VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12);
/**
* Returns all {@link JavaCore}{@code #VERSION_*} levels in the order of their
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
index 25769a457e..359c9e8a24 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
@@ -6,6 +6,10 @@
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -432,7 +436,7 @@ public class JavaModelManager implements ISaveParticipant, IContentTypeChangeLis
public static class CompilationParticipants {
- private final static int MAX_SOURCE_LEVEL = 11 ; // 1.1 to 1.8 and 9, 10
+ static final int MAX_SOURCE_LEVEL = JavaCore.getAllVersions().size() - 1; // All except VERSION_CLDC_1_1
/*
* The registered compilation participants (a table from int (source level) to Object[])

Back to the top