Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.CARNet.hr!garrison.bnet.hr!gregory.BNet.hr!not-for-mail From: Josip Almasi Newsgroups: comp.lang.java.programmer Subject: Re: dealing with ClassLoaders... Date: Sun, 10 Aug 2014 13:22:15 +0200 Organization: B.net Hrvatska d.o.o. Lines: 36 Message-ID: References: NNTP-Posting-Host: cpe-188-252-131-7.zg5.cable.xnet.hr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: gregory.bnet.hr 1407669735 29175 188.252.131.7 (10 Aug 2014 11:22:15 GMT) X-Complaints-To: abuse@globalnet.hr NNTP-Posting-Date: Sun, 10 Aug 2014 11:22:15 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:29617 On 08/08/2014 08:46 PM, Andreas Leitgeb wrote: >> Don't worry, it won't be silent:> >> Mess up anything, and you get strange ClassCastExceptions. > > Well, if due to a bug all references to a certain class > came from System classloader, then there would not be > any ClassCastExceptions, but no isolation, either. Right, but that the case with clearly divided resposibilites. Not-so-clear situations are different story. Say, I had plugin system, each plugin was embedding a stand-alone app, like web, mail, chat servers... So, each had it's own class loader, for isolation. However, the system needed some internal data from plugins... like, to match username on web server with username on mail server:> Then, I wanted a plugin to communicate with other plugins. Like, to ask my chatbot to send someone a mail. ( http://www.vrspace.org/vrspace-old/VRSpace_presentation/Presentation_pictures/p2_8.jpg ) And so on. Then, what if two of your apps use same lib, and that lib has static collections, and stores some of it's own data into these collections? Note that it may not matter which loader loaded the lib, but instead, which loader loaded the thread that generated object stored to lib's internals! ( new -> Class.currentThread().getClassLoader().loadClass(...) or so) It can go wrong in many ways. Of course, solutions exist for all wrongs, but identifying what went wrong is quite time consuming, because there's so many. Regards...