@Override
   @SuppressWarnings("rawtypes")
   protected Class<?> findClass(String name) throws ClassNotFoundException {
      if (classCache.containsKey(name)) {
         return classCache.get(name);
      }

      for (WeakReference<Bundle> ref : bundles) {
         final Bundle bundle = ref.get();
         // ISPN-4679 may get a null handle from the weak reference
         if (bundle == null) continue;
         if (bundle.getState() == Bundle.ACTIVE) {
            try {
               final Class clazz = bundle.loadClass(name);
               if (clazz != null) {
                  classCache.put(name, clazz);
                  return clazz;
               }
            } catch (Exception ignore) {
            }
         }
      }

      throw new ClassNotFoundException("Could not load requested class : " + name);
   }
@ Override @ SuppressWarnings ( "rawtypes" ) protected Class < ? > findClass ( String name ) throws ClassNotFoundException { if ( classCache . containsKey ( name ) ) { return classCache . get ( name ) ; } for ( WeakReference < Bundle > ref : bundles ) { final Bundle bundle = ref . get ( ) ; if ( bundle == null ) continue ; if ( bundle . getState ( ) == Bundle . ACTIVE ) { try { final Class clazz = bundle . loadClass ( name ) ; if ( clazz != null ) { classCache . put ( name , clazz ) ; return clazz ; } } catch ( Exception ignore ) { } } } throw new ClassNotFoundException ( "Could not load requested class : " + name ) ; }
Load the class and break on first found match.

TODO: Should this throw a different exception or warn if multiple classes were found? Naming
collisions can and do happen in OSGi...