Bug 521843 - [9] Cannot launch JUnit Plugin test with Java 9 instead of
Java 8

Change-Id: I11d9a11f5f48e93785efacf5aa5d5421c1200a3a
diff --git a/org.eclipse.jdt.debug.tests/test plugin/org/eclipse/jdt/debug/testplugin/JavaProjectHelper.java b/org.eclipse.jdt.debug.tests/test plugin/org/eclipse/jdt/debug/testplugin/JavaProjectHelper.java
index 08eb3cf..5ce5fac 100644
--- a/org.eclipse.jdt.debug.tests/test plugin/org/eclipse/jdt/debug/testplugin/JavaProjectHelper.java
+++ b/org.eclipse.jdt.debug.tests/test plugin/org/eclipse/jdt/debug/testplugin/JavaProjectHelper.java
@@ -94,6 +94,15 @@
 	public static boolean isJava8Compatible() {
 		return isCompatible(8);
 	}
+
+	/**
+	 * Returns if the currently running VM is version compatible with Java 9
+	 *
+	 * @return <code>true</code> if a Java 9 (or greater) VM is running <code>false</code> otherwise
+	 */
+	public static boolean isJava9Compatible() {
+		return isCompatible(9);
+	}
 	/**
 	 * Returns if the currently running VM is version compatible with Java 7
 	 *
@@ -142,6 +151,15 @@
 					}
 				} catch (NumberFormatException e) {
 				}
+			} else if (nums.length == 1) {
+				try {
+					int major = Integer.parseInt(nums[0]);
+					if (major >= ver) {
+						return true;
+					}
+				}
+				catch (NumberFormatException e) {
+				}
 			}
 		}
 		return false;
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java
index 6e8ee0f..6237810 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -27,6 +27,7 @@
 import org.eclipse.jdt.debug.tests.breakpoints.HitCountBreakpointsTests;
 import org.eclipse.jdt.debug.tests.breakpoints.ImportBreakpointsTest;
 import org.eclipse.jdt.debug.tests.breakpoints.JavaBreakpointListenerTests;
+import org.eclipse.jdt.debug.tests.breakpoints.JavaThreadEventHandlerTests;
 import org.eclipse.jdt.debug.tests.breakpoints.MethodBreakpointTests;
 import org.eclipse.jdt.debug.tests.breakpoints.MethodBreakpointTests15;
 import org.eclipse.jdt.debug.tests.breakpoints.MiscBreakpointsTests;
@@ -38,7 +39,6 @@
 import org.eclipse.jdt.debug.tests.breakpoints.TestToggleBreakpointsTarget;
 import org.eclipse.jdt.debug.tests.breakpoints.TestToggleBreakpointsTarget8;
 import org.eclipse.jdt.debug.tests.breakpoints.ThreadFilterBreakpointsTests;
-import org.eclipse.jdt.debug.tests.breakpoints.JavaThreadEventHandlerTests;
 import org.eclipse.jdt.debug.tests.breakpoints.TriggerPointBreakpointsTests;
 import org.eclipse.jdt.debug.tests.breakpoints.TypeNameBreakpointTests;
 import org.eclipse.jdt.debug.tests.breakpoints.WatchpointTests;
@@ -250,7 +250,9 @@
 		addTest(new TestSuite(ClasspathContainerTests.class));
 		addTest(new TestSuite(RuntimeClasspathEntryTests.class));
 		addTest(new TestSuite(ClasspathProviderTests.class));
-		addTest(new TestSuite(BootpathTests.class));
+		if (!JavaProjectHelper.isJava9Compatible()) {
+			addTest(new TestSuite(BootpathTests.class));
+		}
 		addTest(new TestSuite(EEDefinitionTests.class));
 
 	//VM Install/Environment tests
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java
index 250f578..8aa727a 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/ClasspathContainerTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2000, 2015 IBM Corporation and others.
+ *  Copyright (c) 2000, 2017 IBM Corporation and others.
  *  All rights reserved. This program and the accompanying materials
  *  are made available under the terms of the Eclipse Public License v1.0
  *  which accompanies this distribution, and is available at
@@ -183,6 +183,9 @@
 	public void testJREContainerIndex() throws Exception {
 		// get the current VM
 		IVMInstall def = JavaRuntime.getDefaultVMInstall();
+		if (JavaRuntime.isModularJava(def)) {
+			return;
+		}
 		LibraryLocation[] libs = JavaRuntime.getLibraryLocations(def);
 		// generate an index for the first library location only (to save time - do not need an index for all libraries)
 		URL indexURL = this.getIndexForLibrary(libs[0]);
@@ -225,6 +228,9 @@
 	public void testJREContainerIndex2() throws Exception {
 		// get the current VM
 		IVMInstall def = JavaRuntime.getDefaultVMInstall();
+		if (JavaRuntime.isModularJava(def)) {
+			return;
+		}
 		LibraryLocation[] libs = JavaRuntime.getLibraryLocations(def);
 		// generate an index for the first library location only (to save time - do not need an index for all libraries)
 		URL indexURL = this.getIndexForLibrary(libs[0]);
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java
index 947f93d..06f626e 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -233,4 +233,8 @@
 
 	public static String MacInstalledJREs_1;
 
+	public static String RunnerBootpathError;
+
+	public static String RunnerBootpathPError;
+
 }
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties
index a06cc29..5a28638 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2000, 2013 IBM Corporation and others.
+# Copyright (c) 2000, 2017 IBM Corporation and others.
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
 # which accompanies this distribution, and is available at
@@ -195,3 +195,5 @@
 VMDefinitionsContainer_7=Installed JRE ''{0}'' removed due to missing id.
 VMDefinitionsContainer_9=Installed JRE of type ''{0}'' removed due to missing install path, name, and id.
 VMDefinitionsContainer_10=Installed JREs
+RunnerBootpathError=Xbootclasspath option have been removed as not supported beyond Java 8.
+RunnerBootpathPError=Xbootclasspath/p option have been removed as not supported beyond Java 8.
\ No newline at end of file
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java
index d91d665..66965c2 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java
@@ -35,6 +35,7 @@
 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
 import org.eclipse.jdt.launching.IVMInstall;
 import org.eclipse.jdt.launching.IVMInstall2;
+import org.eclipse.jdt.launching.JavaRuntime;
 import org.eclipse.jdt.launching.VMRunnerConfiguration;
 import org.eclipse.osgi.util.NLS;
 
@@ -595,18 +596,30 @@
 		String[] appendBootCP= null;
 		Map<String, Object> map = config.getVMSpecificAttributesMap();
 		if (map != null) {
-			prependBootCP= (String[]) map.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_PREPEND);
-			bootCP= (String[]) map.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH);
+			prependBootCP = (String[]) map.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_PREPEND);
+			bootCP = (String[]) map.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH);
+			if (JavaRuntime.isModularJava(fVMInstance)) {
+				if (prependBootCP != null) {
+					prependBootCP = null;
+					LaunchingPlugin.log(LaunchingMessages.RunnerBootpathPError);
+				}
+				if (bootCP != null) {
+					bootCP = null;
+					LaunchingPlugin.log(LaunchingMessages.RunnerBootpathError);
+				}
+			}
 			appendBootCP= (String[]) map.get(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_APPEND);
 		}
-		if (prependBootCP == null && bootCP == null && appendBootCP == null) {
-			// use old single attribute instead of new attributes if not specified
-			bootCP = config.getBootClassPath();
+		if (!JavaRuntime.isModularJava(fVMInstance)) {
+			if (prependBootCP == null && bootCP == null && appendBootCP == null) {
+				// use old single attribute instead of new attributes if not specified
+				bootCP = config.getBootClassPath();
+			}
 		}
-		// Bug 497945 -Temporary testing to see if we can launch inner eclipse in Mac after this.
-		/*
-		 * if (prependBootCP != null) { arguments.add("-Xbootclasspath/p:" + convertClassPath(prependBootCP)); //$NON-NLS-1$ }
-		 */
+		 if (prependBootCP != null) {
+			 arguments.add("-Xbootclasspath/p:" + convertClassPath(prependBootCP)); //$NON-NLS-1$
+		 }
+
 		if (bootCP != null) {
 			if (bootCP.length > 0) {
 				arguments.add("-Xbootclasspath:" + convertClassPath(bootCP)); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/AbstractJavaLaunchConfigurationDelegate.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/AbstractJavaLaunchConfigurationDelegate.java
index 234886e..1430738 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/AbstractJavaLaunchConfigurationDelegate.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/AbstractJavaLaunchConfigurationDelegate.java
@@ -238,6 +238,9 @@
 	 */
 	public String[] getBootpath(ILaunchConfiguration configuration)
 			throws CoreException {
+		if (JavaRuntime.isModularConfiguration(configuration)) {
+			return null;
+		}
 		String[][] paths = getBootpathExt(configuration);
 		String[] pre = paths[0];
 		String[] main = paths[1];