• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassLoader issues

 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I have the following issue :

Three classes (not actual names :
- AppStarter
- App
- StringManager

AppStarter creates a new URLClassLoader and uses that to create an instance of App. App has a static field of type StringManager.

I expected that StringManager instance to have the URLClassLoader as it's classloader, but instead it has the AppClassLoader. The App instance does have the URLClassLoader so that's correct.

App relevant code :



Does anyone have any idea why this is happening? Do fields declared as static always use the AppClassLoader?

Thanks!
 
R van Vliet
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I should add, the URLClassLoader does get a chance to load the class, but it doesnt find it even though this class is in a jar present in the urls[] list of the URLCLassLoader.
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the StringManager class happen to be on the classpath?
If so, the system/application class loader will indeed load the class as per the class loader delegation model.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic