C
chrislewis
I've done some brief searching through the JLS for information on how
exaclty new works - specifically, how the class supplied as an
argument is located (what class loader is used). I haven't found
anything yet, but in my readings I've come to assume that new must use
the class loader of the enclosing class. So if in my application's
main() method I call new MyClass(), the classloader that loaded the
class containing main() (the application class loader) is used to
resolve the class. Is this correct?
Further, I'm looking in to creating a pluggable architecture for my
app and will probably need at least a simple custom class loader.
Let's say I created JarClassLoader and use it within a class loaded by
the AppClassLoader. When I load classes using the JarClassLoader
(assuming that AppClassLoader is the parent of JarClassLoader),
classes loaded via JarClassLoader can have access to those loaded by
AppClassLoader (because its the parent), but the reverse is not true
(classed loaded via JarClassLoader are not available to the rest of
the app loaded by AppClassLoader). Is this correct? If not could
someone fill in the holes?
much appreciated
exaclty new works - specifically, how the class supplied as an
argument is located (what class loader is used). I haven't found
anything yet, but in my readings I've come to assume that new must use
the class loader of the enclosing class. So if in my application's
main() method I call new MyClass(), the classloader that loaded the
class containing main() (the application class loader) is used to
resolve the class. Is this correct?
Further, I'm looking in to creating a pluggable architecture for my
app and will probably need at least a simple custom class loader.
Let's say I created JarClassLoader and use it within a class loaded by
the AppClassLoader. When I load classes using the JarClassLoader
(assuming that AppClassLoader is the parent of JarClassLoader),
classes loaded via JarClassLoader can have access to those loaded by
AppClassLoader (because its the parent), but the reverse is not true
(classed loaded via JarClassLoader are not available to the rest of
the app loaded by AppClassLoader). Is this correct? If not could
someone fill in the holes?
much appreciated