private static Class loadJarPluginMainClass(final Path jarPath,
                                                final List<Path> dependencyJarPaths,
                                                final String pluginMainClassName,
                                                final PluginClassLoaderFactory pluginClassLoaderFactory)
            throws InvalidJarPluginException {
        final URI fileUriJar;
        try {
            fileUriJar = jarPath.toUri();
        } catch (IOError ex) {
            throw new InvalidJarPluginException("[FATAL] JAR plugin path specified is invalid: " + jarPath.toString(),
                                                ex);
        } catch (SecurityException ex) {
            throw new InvalidJarPluginException("Security manager prohibits getting the working directory: "
                                                + jarPath.toString()
                                                + ". Specifying an absolute path for JAR plugin may solve this.",
                                                ex);
        }

        // file:/...
        final URL fileUrlJar;
        try {
            fileUrlJar = fileUriJar.toURL();
        } catch (IllegalArgumentException ex) {
            throw new InvalidJarPluginException("[FATAL/INTERNAL] JAR plugin path as URI is not absolute.", ex);
        } catch (MalformedURLException ex) {
            throw new InvalidJarPluginException("JAR plugin path specified is invalid: " + jarPath.toString(), ex);
        }

        final List<URL> dependencyJarUrls = new ArrayList<>();
        dependencyJarUrls.add(fileUrlJar);
        for (final Path dependencyJarPath : dependencyJarPaths) {
            final URI dependencyJarUri;
            try {
                dependencyJarUri = dependencyJarPath.toUri();
            } catch (IOError ex) {
                throw new InvalidJarPluginException(
                        "[FATAL] Path of dependency specified is invalid: " + dependencyJarPath.toString(), ex);
            } catch (SecurityException ex) {
                throw new InvalidJarPluginException("Security manager prohibits getting the working directory.", ex);
            }

            try {
                dependencyJarUrls.add(dependencyJarUri.toURL());
            } catch (IllegalArgumentException ex) {
                throw new InvalidJarPluginException("[FATAL/INTERNAL] Path of dependency is not absolute.", ex);
            } catch (MalformedURLException ex) {
                throw new InvalidJarPluginException(
                        "Path of dependency specified is invalid: " + dependencyJarUri.toString(), ex);
            }
        }

        final PluginClassLoader pluginClassLoader = pluginClassLoaderFactory.create(
                dependencyJarUrls, JarPluginLoader.class.getClassLoader());

        final Class pluginMainClass;
        try {
            pluginMainClass = pluginClassLoader.loadClass(pluginMainClassName);
        } catch (ClassNotFoundException ex) {
            throw new InvalidJarPluginException("Class " + pluginMainClassName + " not found in " + jarPath.toString(),
                                                ex);
        }

        return pluginMainClass;
    }
Opens JarURLConnection for the given JAR file path.

Note that JarURLConnection does not have {@code disconnect} nor {@code close}.
embulk-core/src/main/java/org/embulk/plugin/jar/JarPluginLoader.java