• Post Reply Bookmark Topic Watch Topic
  • New Topic

ClassLoader issues  RSS feed

 
R van Vliet
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!