// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;

public class MyClassLoader extends URLClassLoader {
    public MyClassLoader(URL[] urls) {
        super(urls);
    }
    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        Class<?> res = super.findClass(name);
        try {
            Method m = res.getMethod("special", new Class[0]);
            m.invoke(null, new Object[0]);
        } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            e.printStackTrace();
        }
        return res;
    }
    public static void main(String[] args) throws Exception {
        ClassLoader cl = new MyClassLoader(new URL[] { new URL("file:///C:/work/") });
        Object o = Class.forName("Dyn", true, cl).newInstance();
    }
}
