This post originated from an RSS feed registered with Java Buzz
by Norman Richards.
Original Post: Rewriting the classpath at runtime
Feed Title: Orb [norman richards]
Feed URL: http://members.capmac.org/~orb/blog.cgi/tech/java?flav=rss
Feed Description: Monkey number 312,978,199
I ran across
an interesting hack to allow you to rewrite the system classpath at
runtime. This is the kind of dumb pointless hack I normally would
do, but I've never run into a case where I've needed to hack the
system classpath like this. If you can call setAccessible() then you
aren't running with any sort of security restrictions and can surely
create a class loader to load the class. Class loading in Java is so
simple that I can't see any reason not to do things the right way.
But still, as a hack for the sake of hacking, I like it.
Judging by the comments on the posting above, some people are
undoubtedly going to try to put this hack in their own code. If you
are one of those people, please put your keyboard down now and report
to the Ministry of Reeducation immediately. We've got some manual
labor for you. (Seriously, though - don't do it)