Tuesday, January 18, 2011

Interesting article on Reloading Java Classes

Look at the code below. TAll the code is trying to achieve is get an instance of iExample. However, kind of complex code.

public class ExampleFactory {
public static IExample newInstance() {
URLClassLoader tmp =
new URLClassLoader(new URL[] {getClassPath()}) {
public Class loadClass(String name) {
if ('example.Example'.equals(name))
return findClass(name);
return super.loadClass(name);

return (IExample)