Creating your own custom classloader is an advanced subject. I've never had to write my own classloader. But I can imagine it could be necessary when you want to load classes in a nonstandard way, or if you need to control certain aspects such as to which libraries the loaded classes have access.
Tomcat for example has its own custom classloader for web applications, which gives each webapp access to the common Tomcat libraries and to the classes in the WEB-INF/classes directory and the libraries in the WEB-INF/lib directory of the webapp.
I've used them to load classes from places outside of the classpath (e.g. a plugins directory for user-added classes), and for having a security manager associated with those classes, so that they're not allowed everything the hosting application is allowed to do.
Was the original question about writing your own ClassLoader class or using custom instances of the existing classes? I've never had to write one, but have made new URLClassLoader instances with modified classpaths.
JUnit uses a classloader trick to reload classes every time you run a test. I don't know if they have custom code or just an instance of URLClassLoader. It's Open Source so you can go take a look.
I used a monitoring tool that inserts bytecode at class load time. They "log" every method entry and exit so they can report invocation counts and performance.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
posted 12 years ago
Whats the difference between URLClassLoader and ClassLoader?
can anybody provide me with a link on this topic so that i can a knowledge i am looking for...
and i can ClassLoader thing will help in CodeCovrage tool?