public class ParallelWorldClassLoader extends ClassLoader implements Closeable
For example, with the following jar file:
/ +- foo +- X.class +- bar +- X.class
ParallelWorldClassLoader
("foo/") would load X.class
from
/foo/X.class
(note that X is defined in the root package, not
foo.X
.
This can be combined with MaskingClassLoader
to mask classes which are loaded by the parent
class loader so that the child class loader
classes living in different folders are loaded
before the parent class loader loads classes living the jar file publicly
visible
For example, with the following jar file:
/ +- foo +- X.class +- bar +-foo +- X.class
ParallelWorldClassLoader
(MaskingClassLoader.class.getClassLoader())
would load foo.X.class
from
/bar/foo.X.class
not the foo.X.class
in the publicly visible place in the jar file, thus
masking the parent classLoader from loading the class from foo.X.class
(note that X is defined in the package foo, not
bar.foo.X
.
Constructor and Description |
---|
ParallelWorldClassLoader(ClassLoader parent,
String prefix) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected Class |
findClass(String name) |
protected URL |
findResource(String name) |
protected Enumeration<URL> |
findResources(String name) |
static URL |
toJarUrl(URL res)
Given the URL inside jar, returns the URL to the jar itself.
|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public ParallelWorldClassLoader(ClassLoader parent, String prefix)
protected Class findClass(String name) throws ClassNotFoundException
findClass
in class ClassLoader
ClassNotFoundException
protected URL findResource(String name)
findResource
in class ClassLoader
protected Enumeration<URL> findResources(String name) throws IOException
findResources
in class ClassLoader
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public static URL toJarUrl(URL res) throws ClassNotFoundException, MalformedURLException
Copyright © 2021 JBoss by Red Hat. All rights reserved.