@Test public void classpathToUrls() throws Exception { String classpath = "../testfunction/target/test-classes" + File.pathSeparator + "../testfunction/target/lib/*"; URL[] urls = Invoker.classpathToUrls(classpath); assertWithMessage(Arrays.toString(urls)).that(urls.length).isGreaterThan(2); File classesDir = new File(urls[0].toURI()); assertWithMessage(classesDir.toString()).that(classesDir.isDirectory()).isTrue(); for (int i = 1; i < urls.length; i++) { URL url = urls[i]; assertThat(url.toString()).endsWith(".jar"); assertWithMessage(url.toString()).that(new File(url.toURI()).isFile()).isTrue(); } }
static URL[] classpathToUrls(String classpath) { String[] components = classpath.split(File.pathSeparator); List<URL> urls = new ArrayList<>(); for (String component : components) { if (component.endsWith(File.separator + "*")) { urls.addAll(jarsIn(component.substring(0, component.length() - 2))); } else { Path path = Paths.get(component); try { urls.add(path.toUri().toURL()); } catch (MalformedURLException e) { throw new UncheckedIOException(e); } } } return urls.toArray(new URL[0]); }
Invoker { static URL[] classpathToUrls(String classpath) { String[] components = classpath.split(File.pathSeparator); List<URL> urls = new ArrayList<>(); for (String component : components) { if (component.endsWith(File.separator + "*")) { urls.addAll(jarsIn(component.substring(0, component.length() - 2))); } else { Path path = Paths.get(component); try { urls.add(path.toUri().toURL()); } catch (MalformedURLException e) { throw new UncheckedIOException(e); } } } return urls.toArray(new URL[0]); } }
Invoker { static URL[] classpathToUrls(String classpath) { String[] components = classpath.split(File.pathSeparator); List<URL> urls = new ArrayList<>(); for (String component : components) { if (component.endsWith(File.separator + "*")) { urls.addAll(jarsIn(component.substring(0, component.length() - 2))); } else { Path path = Paths.get(component); try { urls.add(path.toUri().toURL()); } catch (MalformedURLException e) { throw new UncheckedIOException(e); } } } return urls.toArray(new URL[0]); } Invoker(
      Integer port,
      String functionTarget,
      String functionSignatureType,
      ClassLoader functionClassLoader); }
Invoker { static URL[] classpathToUrls(String classpath) { String[] components = classpath.split(File.pathSeparator); List<URL> urls = new ArrayList<>(); for (String component : components) { if (component.endsWith(File.separator + "*")) { urls.addAll(jarsIn(component.substring(0, component.length() - 2))); } else { Path path = Paths.get(component); try { urls.add(path.toUri().toURL()); } catch (MalformedURLException e) { throw new UncheckedIOException(e); } } } return urls.toArray(new URL[0]); } Invoker(
      Integer port,
      String functionTarget,
      String functionSignatureType,
      ClassLoader functionClassLoader); static void main(String[] args); void startServer(); }
Invoker { static URL[] classpathToUrls(String classpath) { String[] components = classpath.split(File.pathSeparator); List<URL> urls = new ArrayList<>(); for (String component : components) { if (component.endsWith(File.separator + "*")) { urls.addAll(jarsIn(component.substring(0, component.length() - 2))); } else { Path path = Paths.get(component); try { urls.add(path.toUri().toURL()); } catch (MalformedURLException e) { throw new UncheckedIOException(e); } } } return urls.toArray(new URL[0]); } Invoker(
      Integer port,
      String functionTarget,
      String functionSignatureType,
      ClassLoader functionClassLoader); static void main(String[] args); void startServer();  }