| Author |
How to add a method for classLoader
|
chris liao
Greenhorn
Joined: Jul 24, 2005
Posts: 26
|
|
I want to extend URLClassLoader,Which containered a method: addURL(URL url), but why not give us another method: removeURL(URL url) in URLClassLoader?? Now, I need a meothd to remove some url,but I don't how to do about this. Please help me !
|
 |
yash Vi
Ranch Hand
Joined: Jul 17, 2005
Posts: 41
|
|
|
can try extend the URLClassloader and create your own class with a remove method on it.as it is not a final class you can try it.
|
Thanks for your reply and time.<br />Windows 2000,j2sdk1.4.2_08
|
 |
chris liao
Greenhorn
Joined: Jul 24, 2005
Posts: 26
|
|
Thanks! if I extend URLClassLoader and add new method:removeURL in my new ClassLoader. please note the below code in URLClassLoader, protected addURL(URL url){ ucp.addURL(url); } In fact,no removeURL method in URLClassLoader,but I need it appear in my new classLoader,I don't how to write the code about it. please help me !
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
I don't think you can remove a URL from the class loader's list without maybe using reflection to change some private methods to public. That would be a Very Dangerous Thing in most cases. You could get the current list of URLs and create a new class loader that has all off the current ones except the one you want to remove. See if the difference between these two lines makes sense:
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: How to add a method for classLoader
|
|
|