changeset 745:92aa05eff5d1

8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar Reviewed-by: rriggs, dfuchs, lancea, alanb
author joehw
date Wed, 11 Jan 2017 13:08:45 -0800
parents a98174edd246
children 7a532a9a2271
files src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java
diffstat 2 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java	Tue Jan 10 22:15:54 2017 +0300
+++ b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java	Wed Jan 11 13:08:45 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.lang.reflect.Method;
+import java.net.URI;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -332,13 +333,13 @@
      * (com.sun.org.apache.xml.internal) for modular runtime.
      */
     private static EntityResolver createCatalogResolver(ArrayList<URL> urls) throws Exception {
-        // Prepare array of catalog paths
-        String[] paths = urls.stream()
-                             .map(u -> u.toExternalForm())
-                             .toArray(c -> new String[c]);
+        // Prepare array of catalog URIs
+        URI[] uris = urls.stream()
+                             .map(u -> URI.create(u.toExternalForm()))
+                             .toArray(URI[]::new);
 
         //Create CatalogResolver with new JDK9+ API
-        return (EntityResolver) CatalogManager.catalogResolver(catalogFeatures, paths);
+        return (EntityResolver) CatalogManager.catalogResolver(catalogFeatures, uris);
     }
 
     // Cache CatalogFeatures instance for future usages.
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java	Tue Jan 10 22:15:54 2017 +0300
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java	Wed Jan 11 13:08:45 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -777,13 +777,13 @@
      * Adds a new catalog file.
      */
     public void addCatalog(File catalogFile) throws IOException {
-        String newUrl = catalogFile.getPath();
+        URI newUrl = catalogFile.toURI();
         if (!catalogUrls.contains(newUrl)) {
             catalogUrls.add(newUrl);
         }
         try {
             entityResolver = CatalogManager.catalogResolver(catalogFeatures,
-                                catalogUrls.toArray(new String[0]));
+                                catalogUrls.stream().toArray(URI[]::new));
         } catch (Exception ex) {
             entityResolver = null;
         }
@@ -791,7 +791,7 @@
 
     // Since javax.xml.catalog is unmodifiable we need to track catalog
     // URLs added and create new catalog each time addCatalog is called
-    private final ArrayList<String> catalogUrls = new ArrayList<String>();
+    private final ArrayList<URI> catalogUrls = new ArrayList<>();
 
     // Cache CatalogFeatures instance for future usages.
     // Resolve feature is set to "continue" value for backward compatibility.