Hi kamranzafar!
First, JCL is really great! I made some small modifications to JCL for my Webstart project. I don't know if they could be useful to others so I post them here
The first one is some kind of destroy method for JarClassLoader. It's useful for me because I have some kind of multigame and use this method to unload claseses and resources from JarClassLoader when not in use. (after seeing the unloadClass of JarClassLoader, maybe the unloading of resources could be done with the unloadClass(key) method too).
public void destroy() {
for (String key : getLoadedClasses().keySet())
unloadClass(key);
for (String key : getLoadedResources().keySet())
classpathResources.unload(key);
}
The second one is more related to the webstart and the ProtectionDomain/CodeSource. For that working I had to update public Class loadClass(String className, boolean resolveIt)
of LocalLoader, to include in the defineClass
method the protectionDomain (Maybe this is related to #1 issue Set ProtectionDomain/CodeSource??.
result = defineClass( className, classBytes, 0, classBytes.length, getClass().getProtectionDomain());
I think it could also be helpful a constructor for JarClassLoader that receives a parent class loader, for example to do something like this.
jcl = new JarClassLoader(new SecureClassLoader() {
@Override
protected PermissionCollection getPermissions(CodeSource codesource) {
PermissionCollection pcol = super.getPermissions(codesource);
pcol.add(new AllPermission());
return (pcol);
}
});
The last one, I don't implement it yet, but is a public Enumeration<URL> getResources(String name) throws IOException
method for each of the ProxyClassLoader implementations. I think the implementations could be something like:
public Enumeration<URL> getResources(String name) throws IOException
{
return getSystemResources(name);
}
public Enumeration<URL> getResources(String name) throws IOException
{
return getParent().getResources(name);
}
public Enumeration<URL> getResources(String name) throws IOException
{
return getClass().getClassLoader().getResources(name);
}
public Enumeration<URL> getResources(String name) throws IOException
{
return Thread.currentThread().getContextClassLoader().getResources(name);
}
Tell me what you think about them as I can learn from your knowledge in classloading!!!