--- old/modules/web/src/main/java/com/sun/webkit/network/URLs.java 2014-11-26 15:38:03.000000000 +0300 +++ new/modules/web/src/main/java/com/sun/webkit/network/URLs.java 2014-11-26 15:38:03.000000000 +0300 @@ -28,6 +28,8 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLStreamHandler; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -36,7 +38,7 @@ * A collection of static methods for URL creation. */ public final class URLs { - + /** * The mapping between WebPane-specific protocol names and their * respective handlers. @@ -81,7 +83,7 @@ * @throws MalformedURLException if no protocol is specified, or an * unknown protocol is found. */ - public static URL newURL(URL context, String spec) + public static URL newURL(final URL context, final String spec) throws MalformedURLException { try { @@ -89,16 +91,29 @@ return new URL(context, spec); } catch (MalformedURLException ex) { // Try WebPane-specific protocol handler, if any - URLStreamHandler handler = null; int colonPosition = spec.indexOf(':'); if (colonPosition != -1) { - handler = handlerMap.get( - spec.substring(0, colonPosition).toLowerCase()); - } - if (handler == null) { - throw ex; + final URLStreamHandler handler = handlerMap.get( + spec.substring(0, colonPosition).toLowerCase()); + + try { + // We should be able to specify one of our stream handlers for the URL + // when running as an applet or a web start app. + return AccessController.doPrivileged((PrivilegedAction) () -> { + try { + return new URL(context, spec, handler); + } catch (MalformedURLException muex) { + throw new RuntimeException(muex); + } + }); + } catch (RuntimeException re) { + if (re.getCause() instanceof MalformedURLException) { + throw (MalformedURLException)re.getCause(); + } + throw re; + } } - return new URL(context, spec, handler); + throw ex; } } }