This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Eclipse Collections Categorically: Level up your programming game and have Donald Raab on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem using ClassLoader

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm having the following problem using my own ClassLoader.
Basically I need to dynamically load classes contained inside a JAR files, so I followed instructions for creating my own class loader. I did it, and after some problems, now I'm loading the classes through my own class loader.
The problem is that after releasing all references for my own class loader, it is still possible to load the classes from the JAR file even that the classloader in which the classes were resolved seems to be garbage-collected.
Does anybody know how to re-resolve a class? Or how to probide a solution to this problem?

Regards,

Fuad Abinader
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'd be surprised if the classloader was collected. it can't go untill all references to it are gone, all class objects of classes it loaded are gone, and of course all classes it loaded are gone.

I think you may even need a jvm switch to get classloaders to be collected because of the implications for static methods and data.
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe we could make sure that your ClassLoader is garbage collected. Extend your ClassLoader and override its finalize method. Write a message to the screen that says "I am about to be garbage collected". When you see that message on the console, then you must know, for sure, that your ClassLoader has been garbage collected.

After that, try to reload the classes. If your ClassLoader is gone and your Application ClassLoader do not have access to the jar file in its classpath, then it should throw an exception.

At least that's what I think.
[ May 17, 2006: Message edited by: Edwin Dalorzo ]
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic