Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #29498

Re: dealing with ClassLoaders...

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: dealing with ClassLoaders...
Date Fri, 01 Aug 2014 17:32:40 -0400
Organization A noiseless patient Spider
Lines 46
Message-ID <lrh11s$eqq$1@dont-email.me> (permalink)
References <slrnltl6t2.fp3.avl@login.logic.tuwien.ac.at> <lre9rv$mnu$1@dont-email.me> <slrnltn8l2.fp3.avl@login.logic.tuwien.ac.at> <slrnlto0hg.fp3.avl@login.logic.tuwien.ac.at>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Fri, 1 Aug 2014 21:32:44 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="15194"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194wTaFANb3/v/MSZ1CasvX"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0
In-Reply-To <slrnlto0hg.fp3.avl@login.logic.tuwien.ac.at>
Cancel-Lock sha1:Sdi2gWhtOidAKpx7ke1iDR4s/oA=
Xref csiph.com comp.lang.java.programmer:29498

Show key headers only | View raw


On 8/1/2014 5:10 PM, Andreas Leitgeb wrote:
> Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> wrote:
>> Martin Gregorie <martin@address-in-sig.invalid> wrote:
>>> public class MAClassLoader extends ClassLoader
>>> {
>>    [ no snip ]
>>> }
>>> I hope this is useful info.
>
> On further examination, I think it isn't as simple as that.
> Essentially, this "empty" ClassLoader-subclass would pass
> everything through to the parent classloader (or the pre-
> mordial one, absent a parent) and thus not be associated to
> any of the classes loaded through it, thus provide no
> isolation at all.

     That conclusion may be worth re-examining.  Just because
MAClassLoader is a subclass of ClassLoader and uses methods
of the latter to do all its dirty work, it doesn't mean the
classes aren't loaded by MAClassLoader.  I'd suggest a quick
experiment: Load a class with MAClassLoader, instantiate an
instance thereof, and see what inst.getClass().getClassLoader()
says.

     It must be admitted, though, that ClassLoader is a bit
weird.  An abstract class all of whose methods are concrete?
Bizarre ...

     FWIW, I have successfully used

	private static class Loader extends ClassLoader {
	   private Class<?> load(byte[] classFile) {
	      Class<?> clown = defineClass(
	         null, classFile, 0, classFile.length);
	      resolveClass(clown);
	      return clown;
	   }
	}

... to load many distinct classes with identical package and
class names, which suggests there's at least some degree of
isolation present even though all the actual work is done by
ClassLoader itself.

-- 
esosman@comcast-dot-net.invalid

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-07-31 19:40 +0000
  Re: dealing with ClassLoaders... Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-31 20:44 +0000
    Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 14:22 +0000
      Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 21:10 +0000
        Re: dealing with ClassLoaders... Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-01 17:32 -0400
          Re: dealing with ClassLoaders... Joerg Meier <joergmmeier@arcor.de> - 2014-08-02 01:21 +0200
          Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-02 00:00 +0000
        Re: dealing with ClassLoaders... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-01 21:45 +0000
          Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 23:14 +0000
            Re: dealing with ClassLoaders... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-02 00:35 +0000
              Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-05 15:38 +0000
  Re: dealing with ClassLoaders... Silvio <silvio@internet.com> - 2014-08-01 13:31 +0200
    Re: dealing with ClassLoaders... Silvio <silvio@internet.com> - 2014-08-01 13:37 +0200
      Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 16:06 +0000
  Re: dealing with ClassLoaders... "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-08-01 13:19 +0100
    Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 15:51 +0000
  Re: dealing with ClassLoaders... Josip Almasi <joe@vrspace.org> - 2014-08-01 15:55 +0200
    Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-04 15:12 +0000
      Re: dealing with ClassLoaders... Mike Amling <mamling@chaff.us> - 2014-08-04 19:53 -0500
        Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-05 15:16 +0000
      Re: dealing with ClassLoaders... Josip Almasi <joe@vrspace.org> - 2014-08-08 11:53 +0200
        Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-08 18:46 +0000
          Re: dealing with ClassLoaders... Josip Almasi <joe@vrspace.org> - 2014-08-10 13:22 +0200
            Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-12 17:16 +0000

csiph-web