8178726: Can't load classes from classpath if it is a UNC share

Reviewed-by: alanb, weijun, chegar
This commit is contained in:
Volker Simonis 2017-04-19 14:17:46 +02:00
parent 2c30798b30
commit fbe2a956f9

View File

@ -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 @@ public class ClassLoaders {
*/
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;