Richard S. Hall wrote:
Upayavira wrote:

I was working under the impression (potentially mistaken) that you ask a classloader for a class, and that classloader defers to its parent, and if its parent doesn't find the class it looks for it in its own classpath. (This understanding comes from some limited work with the AntClassLoader).



Your understanding is correct.

In this case, you could intercept the request before you defer to the System/Parent classloader. Are you saying that that _couldn't_ work?



No, it would really work, because you cannot force everyone to use your class loader to load their classes. Certainly Felix can force bundles to use its class loader, but that is about it.

For example, assume I write MyHost:

   public class MyHost {
      Felix felix = null;
      public MyHost() {
         URL.setURLStreamHandlerFactory(...);
         felix = new Felix();
      }
   }

In such a situation, Felix has no control over the class loader loading MyHost.class, so URL.class would be loaded by some other class loader (most likely the standard app class loader).

But if that MyHost code is running within a bundle, surely it would use Felix's classloader?

What scenarios are there under which an app running in an OSGi container would _not_ use the Felix classloader? That is, without the Felix Classlaoder being somewhere in the classloader chain?

Regards, Upayavira

Reply via email to