• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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 ]
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic