@Substitute private static URLStreamHandler getURLStreamHandler(String protocol) { return JavaNetSubstitutions.getURLStreamHandler(protocol); } }
static URLStreamHandler getURLStreamHandler(String protocol) { URLStreamHandler result = URLProtocolsSupport.get(protocol); if (result == null) { if (onDemandProtocols.contains(protocol)) { unsupported("Accessing an URL protocol that was not enabled. The URL protocol " + protocol + " is supported but not enabled by default. It must be enabled by adding the " + enableProtocolsOption + protocol + " option to the native-image command."); } else { unsupported("Accessing an URL protocol that was not enabled. The URL protocol " + protocol + " is not tested and might not work as expected. It can be enabled by adding the " + enableProtocolsOption + protocol + " option to the native-image command."); } } return result; }
@Override public void duringSetup(DuringSetupAccess access) { JavaNetSubstitutions.defaultProtocols.forEach(protocol -> { boolean registered = JavaNetSubstitutions.addURLStreamHandler(protocol); VMError.guarantee(registered, "The URL protocol " + protocol + " is not available."); }); for (String protocol : OptionUtils.flatten(",", SubstrateOptions.EnableURLProtocols.getValue())) { if (JavaNetSubstitutions.defaultProtocols.contains(protocol)) { printWarning("The URL protocol " + protocol + " is enabled by default. " + "The option " + JavaNetSubstitutions.enableProtocolsOption + protocol + " is not needed."); } else if (JavaNetSubstitutions.onDemandProtocols.contains(protocol)) { boolean registered = JavaNetSubstitutions.addURLStreamHandler(protocol); VMError.guarantee(registered, "The URL protocol " + protocol + " is not available."); } else { printWarning("The URL protocol " + protocol + " is not tested and might not work as expected." + System.lineSeparator() + JavaNetSubstitutions.supportedProtocols()); boolean registered = JavaNetSubstitutions.addURLStreamHandler(protocol); if (!registered) { printWarning("Registering the " + protocol + " URL protocol failed. " + "It will not be available at runtime." + System.lineSeparator()); } } } }