Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is this how I properly make it use my AppClassLoader?

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java 1.4, there's a System property "-Djava.system.class.loader" that allows you to make it use your classloader ass the application (or system) classloader. You need only one constructor: YourClassLoader(ClassLoader parent).
When I use the system property, it does instantiate my classloader (which extends URLClassLoader) but when I check on a class to see what loaded it, it says "sun.misc.Launcher$AppClassLoader" (hang on a sec). HOWEVER, if I pass null instead of "parent" to super(), then the classes which were loaded explicitly now say they were loaded by my classloader. Is this a proper way to do this? Am I right to pass null as the parent of my System classloader?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic