ExpansibleURLClassLoader extends URLClassLoader { public void addUrl(final URL url) { URL[] urls = getURLs(); if (Arrays.asList(urls).contains(url)) { return; } addURL(url); } ExpansibleURLClassLoader(final URL[] urls);  ExpansibleURLClassLoader(final URL[] urls, final ClassLoader parent); void addUrl(final URL url);  }
@Test public void checkAdditionNewURL() throws Exception { URL url1 = new URL("http", "host", 9000, "filename1"); URL url2 = new URL("http", "host", 9000, "filename2"); URL url3 = new URL("http", "host", 9000, "filename1"); ExpansibleURLClassLoader cl = new ExpansibleURLClassLoader(new URL[]{url1}); assertNotNull(cl); cl.addUrl(url2); cl.addUrl(url3); URL[] result = cl.getURLs(); assertSame(result[0], url1); assertSame(result[1], url2); assertEquals(result.length, 2); }