• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add a method for classLoader

 
chris liao
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
chris liao
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic