Horaci Macias
2004-05-13 09:04:25 UTC
I've got two classloaders, say parent and child. They both use the default delegation model and parent is the parent classloader of child.
Now imagine the following interface and class:
package testing.java.net.url;
interface Intf
{
void a();
}
package testing.java.net.url;
public class Impl implements Intf{
void a(){}
}
They are each in a separate .java file, and the interface is in the parent classloader whereas the class is in the child classloader. I thought that trying to load the class from the child classloader shouldn't be a problem, but in fact it is. I'm getting the following exception when loading Impl:
java.lang.IllegalAccessError: class testing.java.net.url.Impl cannot access its superinterface testing.java.net.url.Intf
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Note that the interface is not public, but it is in the same package as the implementation. If I make the interface public then everything works fine, but shouldn't it also work with the interface as is it? Am I missing something?
Thanks in advance,
Horaci
This message has been scanned for viruses by MailControl - www.mailcontrol.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
You may be interested in our new J2EE Web Tier course:
May 17 2004, in Torrance, CA
June 21 2004, in Boston, MA
http://www.develop.com/courses/javawebtierls
View archives and manage your subscription(s) at http://discuss.develop.com
Now imagine the following interface and class:
package testing.java.net.url;
interface Intf
{
void a();
}
package testing.java.net.url;
public class Impl implements Intf{
void a(){}
}
They are each in a separate .java file, and the interface is in the parent classloader whereas the class is in the child classloader. I thought that trying to load the class from the child classloader shouldn't be a problem, but in fact it is. I'm getting the following exception when loading Impl:
java.lang.IllegalAccessError: class testing.java.net.url.Impl cannot access its superinterface testing.java.net.url.Intf
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Note that the interface is not public, but it is in the same package as the implementation. If I make the interface public then everything works fine, but shouldn't it also work with the interface as is it? Am I missing something?
Thanks in advance,
Horaci
This message has been scanned for viruses by MailControl - www.mailcontrol.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
You may be interested in our new J2EE Web Tier course:
May 17 2004, in Torrance, CA
June 21 2004, in Boston, MA
http://www.develop.com/courses/javawebtierls
View archives and manage your subscription(s) at http://discuss.develop.com