• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

spacenames of a class loader

 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question:
Does a class loader stores references for any class loaded by its parents after a request from itself to load a class? In this way the set of classes loaded for a class loader and the returned ones by its parent after a request would comprise the spacename of this class loader.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java uses packages to control NameSpaces.

From the JVM Specification:

If unique package names are not used, then package name conflicts may arise far from the point of creation of either of the conflicting packages. This may create a situation that is difficult or impossible for the user or programmer to resolve. The class ClassLoader can be used to isolate packages with the same name from each other in those cases where the packages will have constrained interactions, but not in a way that is transparent to a na�ve program.
 
Junaid Bhatra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is no. Classes loaded by different classloaders are in separate namespaces, irrespective of the fact that it may have been delegated by a child to it's parent. If a parent loaded a class, it keeps a reference to it, and the class belongs to it's namespace (also refereed to as the run-time package).

Originally posted by Jose Botella:
Question:
Does a class loader stores references for any class loaded by its parents after a request from itself to load a class? In this way the set of classes loaded for a class loader and the returned ones by its parent after a request would comprise the spacename of this class loader.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic