Every Java Class has a reference to the class loader that loaded it. Classes of the same name loaded by two different class loaders are considered to be completely different. This causes instanceof checks to fail, even if the class is identical in both loaders. As a result, you need to be very careful when using the disposable Class Loader feature. It is very easy to find yourself in a situation where you have two components that appear to be identical, but are in fact inconsistent.

For instance, suppose you:

If arbitrary2 resolves arbitrary1 as an Object and casts it to the type Arbitrary, a ClassCastException is thrown. The disposable Class Loader feature, therefore, is really most helpful when you have a set of classes to be reloaded whose instances are easy to completely expunge from the server prior to creating a Class Loader.

loading table of contents...