Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29588
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: dealing with ClassLoaders... |
| Date | Fri, 8 Aug 2014 18:46:54 +0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 44 |
| Message-ID | <slrnlua6ou.fp3.avl@login.logic.tuwien.ac.at> (permalink) |
| References | <slrnltl6t2.fp3.avl@login.logic.tuwien.ac.at> <lrg69c$6r3$1@gregory.bnet.hr> <slrnltv8mj.fp3.avl@login.logic.tuwien.ac.at> <ls26n0$jrp$1@gregory.bnet.hr> |
| Reply-To | avl@logic.at |
| Injection-Date | Fri, 8 Aug 2014 18:46:54 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="7fd0c836d94caf9f0b88d96117d7c68e"; logging-data="18345"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uK3pY8XmeqqcOaDUXpE1K" |
| User-Agent | slrn/pre1.0.0-18 (Linux) |
| Cancel-Lock | sha1:ptfsBJyUb1dO8dVeNAjEBGTvemw= |
| Xref | csiph.com comp.lang.java.programmer:29588 |
Show key headers only | View raw
Josip Almasi <joe@vrspace.org> wrote: > On 08/04/2014 05:12 PM, Andreas Leitgeb wrote: >> But it seems like it doesn't really make it easy to use it >> that way. > Noone said it's easy;) ;) > 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. Anyway, I got the classloader working well enough for my needs and I posted the final snippet somewhere in this thread. I used URLs, because that's what getSystemResource() gives me. They need not be remote (and in my case aren't remote). >>> Also, make sure your loaders don't load the same packages. I think I got confused about this advice, in that I thought it was meant to point out a technical requirement, when it really was just a hint (and a good one, btw). > I used something like > JarEntry entry = (JarEntry) jarFile.getEntry( name+".class" ); > InputStream stream = jarFile.getInputStream(entry); > int size = (int) entry.getSize(); > byte[] code = new byte[size]; > I also stated with URL but gave it up, because of unknown length. I didn't really want to hardcode any particular way to access the class-files. They may be in Jar file after deploy, but e.g. in eclipse they're just plain files. Even at the cost of having to grow the ByteArrayOutputStream. Thanks for caring PS: Right after I got a "safe-point" with a working custom classloader, I started un-static'izing the relevant classes. I see myself at 80% done, but the remaining 80% will still be rather tough... ;-)
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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