I have a ClassLoader that has already loaded a definition of a class. However, I want to replace the existing definition of the class with that from a .class file on disk.
I know that if I call the
public URLClassLoader(URL[] urls,
ClassLoader parent)
constructor, I can add the URL containing the directory containing the .class file. However, "The URLs will be searched in the order specified for classes and resources after first searching in the specified parent class loader." I want the URLs searched first, since they contain the new class definitions that I want to use in place of the old ones.
I can only use Java 5, not Java 6.
Is there a way I can do this? A way I can replace the definition of an already defined class with a new definition?