Package jodd.util.cl

Examples of jodd.util.cl.ExtendedURLClassLoader


    defaultClassLoaderStrategy.setLoadArrayClassByComponentTypes(true);

    URLClassLoader parentClassloader = (URLClassLoader)this.getClass().getClassLoader();
    URL[] urls = parentClassloader.getURLs();
    ExtendedURLClassLoader excl = new ExtendedURLClassLoader(urls, parentClassloader, false);

    Class dummyClass = ClassLoaderUtil.loadClass(dummyClassName, excl);
    assertFalse(Dummy.class == dummyClass); // classes are NOT the same as they are loaded by different class loaders
    assertEquals(Dummy.class.getName(), dummyClass.getName());
View Full Code Here


  @Test
  public void testLoadSystemClasses() throws ClassNotFoundException {
    URL[] urls = new URL[0];

    // parent-first
    ExtendedURLClassLoader cl1 = new ExtendedURLClassLoader(urls, null, true);

    Class c1 = cl1.loadClass("java.lang.String");
    assertEquals(String.class, c1);

    // parent-last, still loaded by system loader
    ExtendedURLClassLoader cl2 = new ExtendedURLClassLoader(urls, null, false);

    Class c2 = cl2.loadClass("java.lang.String");
    assertEquals(String.class, c2);

    assertEquals(c1, c2);
  }
View Full Code Here

    URL[] urls = thisClassLoader.getURLs();

    String packageName = this.getClass().getPackage().getName();

    // parent-first
    ExtendedURLClassLoader cl1 = new ExtendedURLClassLoader(urls, null, true);

    Class c1 = cl1.loadClass(packageName + ".testdata.A");

    // parent-last, still loaded by system loader
    ExtendedURLClassLoader cl2 = new ExtendedURLClassLoader(urls, null, false);

    Class c2 = cl2.loadClass(packageName + ".testdata.A");

    assertFalse(c1.equals(c2));

    assertEquals(c1.getName(), c2.getName());
  }
View Full Code Here

    FileUtil.writeString(resourceFile, "RESOURCE CONTENT");
    resourceFile.deleteOnExit();

    URL[] urls = new URL[] {FileUtil.toURL(temp)};

    ExtendedURLClassLoader cl1 = new ExtendedURLClassLoader(urls, null, true);

    URL res = cl1.getResource("data");

    assertEquals(res, FileUtil.toURL(resourceFile));

    Enumeration<URL> enums = cl1.getResources("data");

    assertTrue(enums.hasMoreElements());
    assertEquals(res, enums.nextElement());

    FileUtil.deleteDir(temp);
View Full Code Here

TOP

Related Classes of jodd.util.cl.ExtendedURLClassLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.