Fix mdsal-it-base with JDK9+ 04/79104/4
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 1 Jan 2019 22:09:51 +0000 (23:09 +0100)
committerStephen Kitt <skitt@redhat.com>
Thu, 3 Jan 2019 10:17:09 +0000 (10:17 +0000)
With JDK9+ karaf-4.2.2+ requires additional VMOptions, make sure
we pass them down so the container can boot up when run with JDK9+.

Change-Id: I77760b6e48b3f4335c382a6da1e9770a912b4467
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/mdsal-it-base/src/main/java/org/opendaylight/controller/mdsal/it/base/AbstractMdsalTestBase.java

index a5fc651..6d31034 100644 (file)
@@ -21,11 +21,14 @@ import java.io.File;
 import javax.inject.Inject;
 import org.junit.Before;
 import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.MavenUtils;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.OptionUtils;
+import org.ops4j.pax.exam.karaf.container.internal.JavaVersionUtil;
 import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
 import org.ops4j.pax.exam.options.MavenUrlReference;
+import org.ops4j.pax.exam.options.extra.VMOption;
 import org.ops4j.pax.exam.util.Filter;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -131,6 +134,38 @@ public abstract class AbstractMdsalTestBase {
                 mvnLocalRepoOption(),
                 configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
                 editConfigurationFilePut(ETC_ORG_OPS4J_PAX_LOGGING_CFG, "log4j2.rootLogger.level", "INFO") };
+
+        if (JavaVersionUtil.getMajorVersion() >= 9) {
+            final String karafVersion = MavenUtils.getArtifactVersion("org.apache.karaf.features",
+                "org.apache.karaf.features.core");
+            options = OptionUtils.combine(options, new VMOption[] {
+                    new VMOption("--add-reads=java.xml=java.logging"),
+                    new VMOption("--add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED"),
+                    new VMOption("--patch-module"),
+                    new VMOption("java.base=lib/endorsed/org.apache.karaf.specs.locator-" + karafVersion + ".jar"),
+                    new VMOption("--patch-module"),
+                    new VMOption("java.xml=lib/endorsed/org.apache.karaf.specs.java.xml-" + karafVersion + ".jar"),
+                    new VMOption("--add-opens"),
+                    new VMOption("java.base/java.security=ALL-UNNAMED"),
+                    new VMOption("--add-opens"),
+                    new VMOption("java.base/java.net=ALL-UNNAMED"),
+                    new VMOption("--add-opens"),
+                    new VMOption("java.base/java.lang=ALL-UNNAMED"),
+                    new VMOption("--add-opens"),
+                    new VMOption("java.base/java.util=ALL-UNNAMED"),
+                    new VMOption("--add-opens"),
+                    new VMOption("java.naming/javax.naming.spi=ALL-UNNAMED"),
+                    new VMOption("--add-opens"),
+                    new VMOption("java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"),
+                    new VMOption("--add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED"),
+                    new VMOption("--add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED"),
+                    new VMOption("--add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED"),
+                    new VMOption("--add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED"),
+                    new VMOption("-classpath"),
+                    new VMOption("lib/jdk9plus/*" + File.pathSeparator + "lib/boot/*")
+            });
+        }
+
         return OptionUtils.combine(options, getAdditionalOptions());
     }
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.