ClassLoader classloader = getClassLoader();
if (classloader == null)
throw new IllegalStateException("ClassLoader no longer exists: " + classLoaderString);
if (classloader instanceof RepositoryClassLoader == false)
throw new IllegalStateException("ClassLoader is not an instanceof RepositoryClassLoader " + classLoaderString);
RepositoryClassLoader repositoryClassLoader = (RepositoryClassLoader) classloader;
LoaderRepository loaderRepository = repositoryClassLoader.getLoaderRepository();
if (loaderRepository == null)
throw new IllegalStateException("ClassLoader has been undeployed: " + classLoaderString);
if (loaderRepository instanceof HeirarchicalLoaderRepository3 == false)
throw new IllegalStateException("Repository " + loaderRepository + " for classlaoder " + classLoaderString + " is not an HeirarchicalLoaderRepository3");
return (HeirarchicalLoaderRepository3) loaderRepository;