Prev: IllegalAccessError - Super/sub-types loaded with different classloaders
Next: IllegalAccessError - Super/sub-types loaded with different classloaders
From: Mike Schilling on 25 Jul 2010 11:14 "Lew" <noone(a)lewscanon.com> wrote in message news:i2hij6$epj$2(a)news.albasani.net... > In general, using a different classloader breaks inheritance. Which is why all classes must be loaded by the same system classloader that loads Object :-)
From: Mike Schilling on 25 Jul 2010 14:05
"Lew" <noone(a)lewscanon.com> wrote in message news:i2hl46$j17$1(a)news.albasani.net... > Lew wrote ... >>> In general, using a different classloader breaks inheritance. > > Mike Schilling wrote: >> Which is why all classes must be loaded by the same system classloader >> that loads Object :-) > > You seem to have found one of the exceptions that breaks the "in general" > rule, thus illustrating why I said "in general" in the first place. > > Perhaps I should have said, "In general, using a different classloader > risks breaking inheritance unless you plan accordingly." I foolishly > thought that was implicit in stating the general risk, but I guess some > people need things spelled out in more excruciating explicit detail than > others. ;-) In fact, all non-system classes have ancestors from the system classloader, but you know that. From what I've seen, subclassing in a child classloader is quite safe [1]. What risks are you warning about? 1. Though implementing an interface in a child classloader is an even better idea. |