jersey2-guice-impl/src/main/java/com/squarespace/jersey2/guice/JerseyGuiceUtils.java
@SuppressWarnings({ "unchecked", "rawtypes" })
  private static Set<Binder> toBinders(Map<Key<?>, Binding<?>> bindings) {
    Set<Binder> binders = new HashSet<>();
    
    for (Map.Entry<Key<?>, Binding<?>> entry : bindings.entrySet()) {
      Key<?> key = entry.getKey();
      Binding<?> binding = entry.getValue();
      
      Object source = binding.getSource();
      if (!(source instanceof ElementSource)) {
        
        // Things like the Injector itself don't have an ElementSource.
        if (LOG.isTraceEnabled()) {
          LOG.trace("Adding binding: key={}, source={}", key, source);
        }
        
        binders.add(new GuiceBinder(key, binding));
        continue;
      }
      
      ElementSource element = (ElementSource)source;
      List<String> names = element.getModuleClassNames();
      String name = names.get(0);
      
      // Skip everything that is declared in a JerseyModule
      try {

        Class<?> module;

        // Attempt to load the classes via the context class loader first, in order to support
        // environments that enforce tighter constraints on class loading (such as in an OSGi container)
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if(classLoader != null) {
          module = classLoader.loadClass(name);
        } else {
          module = Class.forName(name);
        }
        if (JerseyModule.class.isAssignableFrom(module)) {
          if (LOG.isTraceEnabled()) {
            LOG.trace("Ignoring binding {} in {}", key, module);
          }
          
          continue;
        }
      } catch (ClassNotFoundException err) {
        // Some modules may not be able to be instantiated directly here as a class if we're running
        // in a container that enforcer tighter class loader constraints (such as the
        // org.ops4j.peaberry.osgi.OSGiModule Guice module when running in an OSGi container),
        // so we're only logging a warning here instead of throwing a hard exception
        if (LOG.isWarnEnabled()) {
          LOG.warn("Unavailable to load class in order to validate module: name={}", name);
        }
      }
      
      binders.add(new GuiceBinder(key, binding));
    }
    
    return binders;
  }
@SuppressWarnings({ "unchecked", "rawtypes" })
  private static Set<Binder> toBinders(Map<Key<?>, Binding<?>> bindings) {
    Set<Binder> binders = new HashSet<>();
    
    for (Map.Entry<Key<?>, Binding<?>> entry : bindings.entrySet()) {
      Key<?> key = entry.getKey();
      Binding<?> binding = entry.getValue();
      
      Object source = binding.getSource();
      if (!(source instanceof ElementSource)) {
        
        // Things like the Injector itself don't have an ElementSource.
        if (LOG.isTraceEnabled()) {
          LOG.trace("Adding binding: key={}, source={}", key, source);
        }
        
        binders.add(new GuiceBinder(key, binding));
        continue;
      }
      
      ElementSource element = (ElementSource)source;
      List<String> names = element.getModuleClassNames();
      String name = names.get(0);
      
      // Skip everything that is declared in a JerseyModule
      try {

        Class<?> module;

        // Attempt to load the classes via the context class loader first, in order to support
        // environments that enforce tighter constraints on class loading (such as in an OSGi container)
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if(classLoader != null) {
          module = classLoader.loadClass(name);
        } else {
          module = Class.forName(name);
        }
        if (JerseyModule.class.isAssignableFrom(module)) {
          if (LOG.isTraceEnabled()) {
            LOG.trace("Ignoring binding {} in {}", key, module);
          }
          
          continue;
        }
      } catch (ClassNotFoundException err) {
        // Some modules may not be able to be instantiated directly here as a class if we're running
        // in a container that enforcer tighter class loader constraints (such as the
        // org.ops4j.peaberry.osgi.OSGiModule Guice module when running in an OSGi container),
        // so we're only logging a warning here instead of throwing a hard exception
        if (LOG.isWarnEnabled()) {
          LOG.warn("Unavailable to load class in order to validate module: name={}", name);
        }
      }
      
      binders.add(new GuiceBinder(key, binding));
    }
    
    return binders;
  }
Turns the given Guice {@link Binding}s into HK2 {@link Binder}s.