IllegalAccessError between class loaders

Hi

I’m dynamically loading classes with a custom class loader (extends URLClassLoader), the trouble is, that some of the classes that are loaded this way, extend classes loaded from the normal class path. When trying to call package/protected utility methods on the base classes, I get IllegalAccessErrors. This is out of my area of knowledge, and google doesn’t appear to be playing on this one :). Does anyone know of a way through security managers, or class loader tricks, or something in the meta inf in the jar or anything that will get these classes playing nicely? :slight_smile:

Cheers

Endolf

If I remember correctly even in the same classloader, package protected methods are not accessable if they are called from within another jar. You may be able to circumvent ths problem by specifying a security.policy file containing a ReflectPermission, but I don’t know if you have to call the utility methods via java.lang.reflect:Method. See http://java.sun.com/j2se/1.4.2/docs/guide/security/permissions.html for some details.

you should use the same classloader other wise you’ll run into that error, however one ugly hack that can suppress the errors is

System.setSecurityManager(null);