I want to make a subclass of URLClassLoader
which, when loadClass()
is invoked, can examine the loaded class with reflection and conditionally decide to pretend it couldn't find that class, so as to allow for a child class loader to handle the loading instead. Would something like the following work?
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
Class<?> c = super.findClass(name);
if (letChildHandleLoad(c))
throw new ClassNotFoundException();
return c;
}