Merge pull request #359 from apache/Memory2-Fix-Tests

Add JPMS arguments to surefire plugin in Java9+
diff --git a/pom.xml b/pom.xml
index 99a4cc8..4a31639 100644
--- a/pom.xml
+++ b/pom.xml
@@ -339,7 +339,7 @@
             <trimStackTrace>false</trimStackTrace>
             <useManifestOnlyJar>false</useManifestOnlyJar>
             <redirectTestOutputToFile>true</redirectTestOutputToFile>
-            <reportsDirectory>./target/test-output/${maven.build.timestamp}</reportsDirectory>
+            <reportsDirectory>${project.build.directory}/test-output/${maven.build.timestamp}</reportsDirectory>
           </configuration>
         </plugin>
 
@@ -659,5 +659,36 @@
         </plugins>
       </build>
     </profile>
+
+    <profile>
+      <id>java9plus</id>
+      <activation>
+        <jdk>[9,)</jdk>
+      </activation>
+      <build>
+        <pluginManagement>
+          <plugins>
+            <plugin>
+              <!-- Apache Parent pom, pluginManagement-->
+              <groupId>org.apache.maven.plugins</groupId>
+              <artifactId>maven-surefire-plugin</artifactId>
+              <version>${maven-surefire-plugin.version}</version>
+              <configuration>
+                <trimStackTrace>false</trimStackTrace>
+                <useManifestOnlyJar>false</useManifestOnlyJar>
+                <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                <reportsDirectory>${project.build.directory}/test-output/${maven.build.timestamp}</reportsDirectory>
+                <argLine>
+                  --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
+                  --add-exports java.base/jdk.internal.ref=ALL-UNNAMED
+                  --add-opens java.base/java.nio=ALL-UNNAMED
+                  --add-opens java.base/sun.nio.ch=ALL-UNNAMED
+                </argLine>
+              </configuration>
+            </plugin>
+          </plugins>
+        </pluginManagement>
+      </build>
+    </profile>
   </profiles>
 </project>