Bug 439930 - LeakTestSuite failing with JDK 9.

- Fix LeakTestSuite when running with Tycho, or through the test
framework (test.xml) with JDK 9 or higher.

Change-Id: I935a7c659dca8b3891b70609de8ad88a7f53b668
Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
diff --git a/org.eclipse.jdt.ui.tests/pom.xml b/org.eclipse.jdt.ui.tests/pom.xml
index c4c44dc..4804962 100644
--- a/org.eclipse.jdt.ui.tests/pom.xml
+++ b/org.eclipse.jdt.ui.tests/pom.xml
@@ -54,4 +54,25 @@
     </plugins>
   </build>
 
+  <profiles>
+    <profile>
+      <activation>
+        <property>
+          <name>AtLeastJava9</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.eclipse.tycho</groupId>
+            <artifactId>tycho-surefire-plugin</artifactId>
+            <configuration>
+                <argLine>--add-modules ALL-SYSTEM --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens jdk.localedata/sun.util.resources.cldr.provider=ALL-UNNAMED --add-opens jdk.localedata/sun.util.resources.provider=ALL-UNNAMED --add-opens java.base/jdk.internal.module=ALL-UNNAMED --add-opens java.base/java.lang.module=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED --add-opens java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/jdk.internal.math=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED</argLine>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
 </project>
diff --git a/org.eclipse.jdt.ui.tests/test.xml b/org.eclipse.jdt.ui.tests/test.xml
index 728db97..805b684 100644
--- a/org.eclipse.jdt.ui.tests/test.xml
+++ b/org.eclipse.jdt.ui.tests/test.xml
@@ -44,11 +44,15 @@
     <property name="jdt-folder" value="${eclipse-home}/jdt_folder"/>
 
     <delete dir="${jdt-folder}" quiet="true"/>
+    <condition property="java9vmargs" value="--add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens jdk.localedata/sun.util.resources.cldr.provider=ALL-UNNAMED --add-opens jdk.localedata/sun.util.resources.provider=ALL-UNNAMED --add-opens java.base/jdk.internal.module=ALL-UNNAMED --add-opens java.base/java.lang.module=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED --add-opens java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/jdk.internal.math=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED" else="">
+      <matches pattern="^(9|10)$" string="${ant.java.version}" />
+    </condition>
     
 	<ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
       <property name="data-dir" value="${jdt-folder}"/>
       <property name="plugin-name" value="${plugin-name}"/>
       <property name="classname" value="org.eclipse.jdt.ui.tests.LeakTestSuite"/>
+      <property name="vmargs" value="${java9vmargs}" />
     </ant>
   </target>