Class ParallelWorldClassLoader
- All Implemented Interfaces:
Closeable
,AutoCloseable
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
.
- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected Class<?>
protected URL
findResource
(String name) protected Enumeration<URL>
findResources
(String name) static URL
Given the URL inside jar, returns the URL to the jar itself.Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
ParallelWorldClassLoader
-
-
Method Details
-
findClass
- Overrides:
findClass
in classClassLoader
- Throws:
ClassNotFoundException
-
findResource
- Overrides:
findResource
in classClassLoader
-
findResources
- Overrides:
findResources
in classClassLoader
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
toJarUrl
Given the URL inside jar, returns the URL to the jar itself.- Parameters:
res
- Resource in a jar- Returns:
- URL to the conaining jar file
- Throws:
ClassNotFoundException
- if res does not denote jar URLMalformedURLException
- if computed URL is invalid
-