8178726: Can't load classes from classpath if it is a UNC share
authorsimonis
Wed, 19 Apr 2017 14:17:46 +0200
changeset 44750 662ff2218c05
parent 44749 d88778ed402c
child 44751 69284bf5d34f
8178726: Can't load classes from classpath if it is a UNC share Reviewed-by: alanb, weijun, chegar
jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Wed Apr 19 13:38:28 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Wed Apr 19 14:17:46 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -256,7 +256,10 @@
      */
     private static URL toFileURL(String s) {
         try {
-            return Paths.get(s).toRealPath().toUri().toURL();
+            // Use an intermediate File object to construct a URI/URL without
+            // authority component as URLClassPath can't handle URLs with a UNC
+            // server name in the authority component.
+            return Paths.get(s).toRealPath().toFile().toURI().toURL();
         } catch (InvalidPathException | IOException ignore) {
             // malformed path string or class path element does not exist
             return null;