Bug 577731 - Merge remote-tracking branch 'origin/master' into BETA_JAVA18

Change-Id: I0e0b1fbda8c91597774da1ba7a54dbecb9d0004f
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/EECompilationParticipant.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/EECompilationParticipant.java
index 560006d..0e2ad71 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/EECompilationParticipant.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/EECompilationParticipant.java
@@ -7,6 +7,9 @@
  * https://www.eclipse.org/legal/epl-2.0/
  *
  * SPDX-License-Identifier: 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.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -234,6 +237,8 @@
 		String version = vMInstall.getJavaVersion();
 		if (version == null) {
 			return null;
+		} else if (version.startsWith(JavaCore.VERSION_18)) {
+			return JavaCore.VERSION_18;
 		} else if (version.startsWith(JavaCore.VERSION_17)) {
 			return JavaCore.VERSION_17;
 		} else if (version.startsWith(JavaCore.VERSION_16)) {
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMType.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMType.java
index d2db66f..b19a99a 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMType.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMType.java
@@ -7,6 +7,9 @@
  * https://www.eclipse.org/legal/epl-2.0/
  *
  * SPDX-License-Identifier: 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.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -846,7 +849,10 @@
 	 */
 	public static URL getDefaultJavadocLocation(String version) {
 		try {
-			if (version.startsWith(JavaCore.VERSION_17)) {
+			if (version.startsWith(JavaCore.VERSION_18)) {
+				// TODO: Needs an update after Java 18 release
+				return new URL("https://docs.oracle.com/en/java/javase/17/docs/api/"); //$NON-NLS-1$
+			} else if (version.startsWith(JavaCore.VERSION_17)) {
 				return new URL("https://docs.oracle.com/en/java/javase/17/docs/api/"); //$NON-NLS-1$
 			} else if (version.startsWith(JavaCore.VERSION_16)) {
 				return new URL("https://docs.oracle.com/en/java/javase/16/docs/api/"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java
index 61d52ca..e148116 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/EnvironmentsManager.java
@@ -7,6 +7,9 @@
  *  https://www.eclipse.org/legal/epl-2.0/
  *
  *  SPDX-License-Identifier: 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.
  *
  *  Contributors:
  *     IBM Corporation - initial API and implementation
@@ -196,7 +199,9 @@
 
 	private String getExecutionEnvironmentCompliance(IExecutionEnvironment executionEnvironment) {
 		String desc = executionEnvironment.getId();
-		if (desc.indexOf(JavaCore.VERSION_17) != -1) {
+		if (desc.indexOf(JavaCore.VERSION_18) != -1) {
+			return JavaCore.VERSION_18;
+		} else if (desc.indexOf(JavaCore.VERSION_17) != -1) {
 			return JavaCore.VERSION_17;
 		} else if (desc.indexOf(JavaCore.VERSION_16) != -1) {
 			return JavaCore.VERSION_16;
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java
index 9a42539..1640eef 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java
@@ -7,6 +7,9 @@
  * https://www.eclipse.org/legal/epl-2.0/
  *
  * SPDX-License-Identifier: 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.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -41,6 +44,7 @@
 
 	// XXX: Note that this string is not yet standardized by OSGi, see http://wiki.osgi.org/wiki/Execution_Environment
 
+	private static final String JavaSE_18 = "JavaSE-18"; //$NON-NLS-1$
 	private static final String JavaSE_17 = "JavaSE-17"; //$NON-NLS-1$
 	private static final String JavaSE_16 = "JavaSE-16"; //$NON-NLS-1$
 	private static final String JavaSE_15 = "JavaSE-15"; //$NON-NLS-1$
@@ -91,7 +95,7 @@
 		mappings.put(JavaSE_1_8, new String[] { JavaSE_1_7 });
 		mappings.put(JavaSE_9, new String[] { JavaSE_1_8 });
 		mappings.put(JavaSE_10, new String[] { JavaSE_9 });
-		mappings.put(JavaSE_10_Plus, new String[] { JavaSE_17 });
+		mappings.put(JavaSE_10_Plus, new String[] { JavaSE_18 });
 		mappings.put(JavaSE_11, new String[] { JavaSE_10 });
 		mappings.put(JavaSE_12, new String[] { JavaSE_11 });
 		mappings.put(JavaSE_13, new String[] { JavaSE_12 });
@@ -99,6 +103,7 @@
 		mappings.put(JavaSE_15, new String[] { JavaSE_14 });
 		mappings.put(JavaSE_16, new String[] { JavaSE_15 });
 		mappings.put(JavaSE_17, new String[] { JavaSE_16 });
+		mappings.put(JavaSE_18, new String[] { JavaSE_17 });
 	}
 	@Override
 	public CompatibleEnvironment[] analyze(IVMInstall vm, IProgressMonitor monitor) throws CoreException {
@@ -124,7 +129,9 @@
 					types = getTypes(CDC_FOUNDATION_1_1);
 				}
 			} else {
-				if (javaVersion.startsWith("17")) { //$NON-NLS-1$
+				if (javaVersion.startsWith("18")) { //$NON-NLS-1$
+					types = getTypes(JavaSE_18);
+				} else if (javaVersion.startsWith("17")) { //$NON-NLS-1$
 					types = getTypes(JavaSE_17);
 				} else if (javaVersion.startsWith("16")) { //$NON-NLS-1$
 					types = getTypes(JavaSE_16);
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
index 8319cdb..e27deb4 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
@@ -7,6 +7,9 @@
  * https://www.eclipse.org/legal/epl-2.0/
  *
  * SPDX-License-Identifier: 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.
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
@@ -3361,8 +3364,11 @@
 				} else if (javaVersion.startsWith(JavaCore.VERSION_17)
 						&& (javaVersion.length() == JavaCore.VERSION_17.length() || javaVersion.charAt(JavaCore.VERSION_17.length()) == '.')) {
 					compliance = JavaCore.VERSION_17;
+				} else if (javaVersion.startsWith(JavaCore.VERSION_18)
+						&& (javaVersion.length() == JavaCore.VERSION_18.length() || javaVersion.charAt(JavaCore.VERSION_18.length()) == '.')) {
+					compliance = JavaCore.VERSION_18;
 				} else {
-					compliance = JavaCore.VERSION_17; // use latest by default
+					compliance = JavaCore.VERSION_18; // use latest by default
 				}
 
             	Hashtable<String, String> options= JavaCore.getOptions();
diff --git a/org.eclipse.jdt.launching/plugin.properties b/org.eclipse.jdt.launching/plugin.properties
index 7a1835d..3a2aa2d 100644
--- a/org.eclipse.jdt.launching/plugin.properties
+++ b/org.eclipse.jdt.launching/plugin.properties
@@ -7,6 +7,10 @@
 # https://www.eclipse.org/legal/epl-2.0/
 # 
 # SPDX-License-Identifier: 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.
+#
 # Contributors:
 #     IBM Corporation - initial API and implementation
 ###############################################################################
@@ -78,6 +82,7 @@
 environment.description.19 = Java Platform, Standard Edition 15
 environment.description.20 = Java Platform, Standard Edition 16
 environment.description.21 = Java Platform, Standard Edition 17
+environment.description.22 = Java Platform, Standard Edition 18
 
 classpathVariableInitializer.deprecated = Use the JRE System Library instead
 
diff --git a/org.eclipse.jdt.launching/plugin.xml b/org.eclipse.jdt.launching/plugin.xml
index 8e6850f..5188019 100644
--- a/org.eclipse.jdt.launching/plugin.xml
+++ b/org.eclipse.jdt.launching/plugin.xml
@@ -9,6 +9,10 @@
      https://www.eclipse.org/legal/epl-2.0/
 
  	 SPDX-License-Identifier: 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.
+
  	
      Contributors:
          IBM Corporation - initial API and implementation
@@ -362,6 +366,11 @@
             description="%environment.description.21"
             id="JavaSE-17"
             compliance="17">
+      </environment>
+      <environment
+            description="%environment.description.22"
+            id="JavaSE-18"
+            compliance="18">
       </environment>         
       <analyzer
             class="org.eclipse.jdt.internal.launching.environments.ExecutionEnvironmentAnalyzer"