Fixes to allow ONOS to build using built in bazel Java 9 JDK

Change-Id: I57b7b3b9a8a28a824b196a72a24c42cd9d04cc59
diff --git a/.bazelrc b/.bazelrc
index 3a1c95b..3bd8166 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -3,10 +3,6 @@
 test --test_summary=terse
 test --test_output=errors
 test --test_verbose_timeout_warnings
-build --host_javabase=@local_jdk//:jdk
-build --javabase=@local_jdk//:jdk
-build --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
-build --host_javabase=@local_jdk//:jdk
-build --distinct_host_configuration=false
+
 #build --disk_cache=~/bazel-cache
 #build --remote_http_cache=http://10.1.10.224:80/cache
diff --git a/core/api/src/main/java/org/onosproject/ui/lion/LionUtils.java b/core/api/src/main/java/org/onosproject/ui/lion/LionUtils.java
index 210a5af..f80d8c4 100644
--- a/core/api/src/main/java/org/onosproject/ui/lion/LionUtils.java
+++ b/core/api/src/main/java/org/onosproject/ui/lion/LionUtils.java
@@ -25,6 +25,7 @@
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.HashSet;
 import java.util.Locale;
 import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
@@ -102,7 +103,7 @@
         // TODO: Review- do we need to store the system default anywhere?
 
         // Useful to log the "user.*" properties for debugging...
-        Set<String> pn = System.getProperties().stringPropertyNames();
+        Set<String> pn = new HashSet<>(System.getProperties().stringPropertyNames());
         pn.removeIf(f -> !(f.startsWith("user.")));
         for (String ukey : pn) {
             log.debug("  {}: {}", ukey, System.getProperty(ukey));
diff --git a/drivers/utilities/BUILD b/drivers/utilities/BUILD
index 88b7c32..a3d550e 100644
--- a/drivers/utilities/BUILD
+++ b/drivers/utilities/BUILD
@@ -1,4 +1,4 @@
-COMPILE_DEPS = CORE_DEPS
+COMPILE_DEPS = CORE_DEPS + JAXB
 
 osgi_jar_with_tests(
     resources = glob(["src/main/resources/**"]),
diff --git a/drivers/utilities/src/test/java/org/onosproject/drivers/utilities/YangXmlUtilsTest.java b/drivers/utilities/src/test/java/org/onosproject/drivers/utilities/YangXmlUtilsTest.java
index f7d898e..7668684 100644
--- a/drivers/utilities/src/test/java/org/onosproject/drivers/utilities/YangXmlUtilsTest.java
+++ b/drivers/utilities/src/test/java/org/onosproject/drivers/utilities/YangXmlUtilsTest.java
@@ -66,6 +66,18 @@
 
     }
 
+    private String canonicalXml(String s) {
+        String[] lines = s.split("\n");
+        StringBuilder xml = new StringBuilder();
+        for (String line : lines) {
+            if (line.contains("<")) {
+                xml.append(line);
+                xml.append("\n");
+            }
+        }
+        return xml.toString().trim();
+    }
+
     /**
      * Tests getting a single object configuration via passing the path and the map of the desired values.
      *
@@ -85,8 +97,8 @@
         assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()),
                      IteratorUtils.toList(cfg.getKeys()));
 
-        assertEquals("Wrong string configuaration", utils.getString(testCreateConfig),
-                     utils.getString(cfg));
+        assertEquals("Wrong string configuaration", canonicalXml(utils.getString(testCreateConfig)),
+                     canonicalXml(utils.getString(cfg)));
     }
 
     /**
@@ -115,8 +127,8 @@
                                              .getXmlConfiguration(OF_CONFIG_XML_PATH, elements));
         assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()),
                      IteratorUtils.toList(cfg.getKeys()));
-        assertEquals("Wrong string configuaration", utils.getString(testCreateConfig),
-                     utils.getString(cfg));
+        assertEquals("Wrong string configuaration", canonicalXml(utils.getString(testCreateConfig)),
+                     canonicalXml(utils.getString(cfg)));
     }
 
     /**
diff --git a/lib/deps.json b/lib/deps.json
index b06dbeb..ae479e5 100644
--- a/lib/deps.json
+++ b/lib/deps.json
@@ -27,6 +27,12 @@
       "//utils/misc:onlab-misc",
       "//utils/osgi:onlab-osgi"
     ],
+    "JAXB": [
+      "jaxb-api",
+      "jaxb-core",
+      "jaxb-impl",
+      "javax.activation"
+    ],
     "TEST": [
       "junit",
       "easymock",
@@ -201,6 +207,10 @@
 
     "javax.inject": "mvn:org.glassfish.hk2.external:javax.inject:2.5.0-b42",
     "javax.ws.rs-api": "mvn:javax.ws.rs:javax.ws.rs-api:2.1",
+    "javax.activation": "mvn:javax.activation:activation:1.1.1",
+    "jaxb-api": "mvn:javax.xml.bind:jaxb-api:2.3.1",
+    "jaxb-core": "mvn:com.sun.xml.bind:jaxb-core:2.3.0.1",
+    "jaxb-impl": "mvn:com.sun.xml.bind:jaxb-impl:2.3.0.1",
     "jersey-client": "mvn:org.glassfish.jersey.core:jersey-client:2.26",
     "jersey-security": "mvn:org.glassfish.jersey.security:oauth2-client:jar:2.26",
     "jersey-common": "mvn:org.glassfish.jersey.core:jersey-common:2.26",
diff --git a/protocols/isis/isisio/BUILD b/protocols/isis/isisio/BUILD
index ad966c4..1aabfcf 100644
--- a/protocols/isis/isisio/BUILD
+++ b/protocols/isis/isisio/BUILD
@@ -1,4 +1,4 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + [
+COMPILE_DEPS = CORE_DEPS + NETTY + JAXB + [
     "@io_netty_netty//jar",
     "//protocols/isis/api:onos-protocols-isis-api",
 ]
diff --git a/protocols/netconf/api/BUILD b/protocols/netconf/api/BUILD
index 2d486c5..61f9d3b 100644
--- a/protocols/netconf/api/BUILD
+++ b/protocols/netconf/api/BUILD
@@ -1,3 +1,3 @@
 osgi_jar_with_tests(
-    deps = CORE_DEPS + JACKSON,
+    deps = CORE_DEPS + JACKSON + JAXB,
 )
diff --git a/protocols/ospf/protocol/BUILD b/protocols/ospf/protocol/BUILD
index 6543146..7de13a9 100644
--- a/protocols/ospf/protocol/BUILD
+++ b/protocols/ospf/protocol/BUILD
@@ -1,4 +1,4 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + [
+COMPILE_DEPS = CORE_DEPS + NETTY + JAXB + [
     "@io_netty_netty//jar",
     "//protocols/ospf/api:onos-protocols-ospf-api",
 ]
diff --git a/tools/build/bazel/generate_workspace.bzl b/tools/build/bazel/generate_workspace.bzl
index fc53d94..9de3d50 100644
--- a/tools/build/bazel/generate_workspace.bzl
+++ b/tools/build/bazel/generate_workspace.bzl
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Tue, 9 Oct 2018 17:26:45 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Thu, 18 Oct 2018 21:04:09 GMT. Do not edit this file manually. *****
 # ***** Use onos-lib-gen *****
 
 load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
@@ -31,6 +31,12 @@
     "//utils/misc:onlab-misc",
     "//utils/osgi:onlab-osgi",
 ]
+JAXB = [
+    "@jaxb_api//jar",
+    "@jaxb_core//jar",
+    "@jaxb_impl//jar",
+    "@javax_activation//jar",
+]
 TEST = [
     "@junit//jar",
     "@easymock//jar",
@@ -496,6 +502,30 @@
             jar_sha256 = "1a4295889416c6972addcd425dfeeee6e6ede110e8b2dc8b49044e9b400ad5db",
             licenses = ["notice"],
             jar_urls = ["http://repo1.maven.org/maven2/javax/ws/rs/javax.ws.rs-api/2.1/javax.ws.rs-api-2.1.jar"],        )
+    if "javax_activation" not in native.existing_rules():
+        java_import_external(
+            name = "javax_activation",
+            jar_sha256 = "ae475120e9fcd99b4b00b38329bd61cdc5eb754eee03fe66c01f50e137724f99",
+            licenses = ["notice"],
+            jar_urls = ["http://repo1.maven.org/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar"],        )
+    if "jaxb_api" not in native.existing_rules():
+        java_import_external(
+            name = "jaxb_api",
+            jar_sha256 = "88b955a0df57880a26a74708bc34f74dcaf8ebf4e78843a28b50eae945732b06",
+            licenses = ["notice"],
+            jar_urls = ["http://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar"],        )
+    if "jaxb_core" not in native.existing_rules():
+        java_import_external(
+            name = "jaxb_core",
+            jar_sha256 = "d2ecba63615f317a11fb55c6468f6a9480f6411c10951d9881bafd9a9a8d0467",
+            licenses = ["notice"],
+            jar_urls = ["http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-core/2.3.0.1/jaxb-core-2.3.0.1.jar"],        )
+    if "jaxb_impl" not in native.existing_rules():
+        java_import_external(
+            name = "jaxb_impl",
+            jar_sha256 = "5ec7bb8dd5d36c9199131e06609409e4ea58bdd5d06fb361d8adfa8887b3c068",
+            licenses = ["notice"],
+            jar_urls = ["http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.3.0.1/jaxb-impl-2.3.0.1.jar"],        )
     if "jersey_client" not in native.existing_rules():
         java_import_external(
             name = "jersey_client",
@@ -1451,6 +1481,10 @@
 artifact_map["@javax_annotation_api_mvn//:javax_annotation_api_mvn"] = "mvn:javax.annotation:javax.annotation-api:jar:1.2"
 artifact_map["@javax_inject//:javax_inject"] = "mvn:org.glassfish.hk2.external:javax.inject:jar:2.5.0-b42"
 artifact_map["@javax_ws_rs_api//:javax_ws_rs_api"] = "mvn:javax.ws.rs:javax.ws.rs-api:jar:2.1"
+artifact_map["@javax_activation//:javax_activation"] = "mvn:javax.activation:activation:jar:NON-OSGI:1.1.1"
+artifact_map["@jaxb_api//:jaxb_api"] = "mvn:javax.xml.bind:jaxb-api:jar:2.3.1"
+artifact_map["@jaxb_core//:jaxb_core"] = "mvn:com.sun.xml.bind:jaxb-core:jar:2.3.0.1"
+artifact_map["@jaxb_impl//:jaxb_impl"] = "mvn:com.sun.xml.bind:jaxb-impl:jar:2.3.0.1"
 artifact_map["@jersey_client//:jersey_client"] = "mvn:org.glassfish.jersey.core:jersey-client:jar:2.26"
 artifact_map["@jersey_security//:jersey_security"] = "mvn:org.glassfish.jersey.security:oauth2-client:jar:NON-OSGI:2.26"
 artifact_map["@jersey_common//:jersey_common"] = "mvn:org.glassfish.jersey.core:jersey-common:jar:2.26"
diff --git a/tools/build_rules/prelude_bazel b/tools/build_rules/prelude_bazel
index 0cdc276..85a7203 100644
--- a/tools/build_rules/prelude_bazel
+++ b/tools/build_rules/prelude_bazel
@@ -14,6 +14,7 @@
     "TEST_REST",
     "ONOS_YANG",
     "ATOMIX",
+    "JAXB",
 )
 load("//tools/build/bazel:osgi_java_library.bzl", "osgi_jar", "osgi_jar_with_tests")
 load("//tools/build/bazel:onos_app.bzl", "onos_app")