jersey2-guice-impl/src/main/java/com/squarespace/jersey2/guice/JerseyGuiceUtils.java
public static ServiceLocator newServiceLocator(String name, ServiceLocator parent) {
    if (parent != null && !(parent instanceof ServiceLocatorImpl)) {
      throw new IllegalArgumentException("name=" + name + ", parent=" + parent);
    }
    
    if (name == null) {
      name = PREFIX;
    }
    
    if (name.endsWith("-")) {
      name += NTH.incrementAndGet();
    }
    
    GuiceServiceLocator locator = new GuiceServiceLocator(name, parent);
    
    DynamicConfigurationImpl config = new DynamicConfigurationImpl(locator);
    
    config.bind(Utilities.getLocatorDescriptor(locator));
    
    ActiveDescriptor<InjectionResolver<javax.inject.Inject>> threeThirtyResolver 
      = newThreeThirtyInjectionResolverDescriptor(locator);
    
    config.addActiveDescriptor(threeThirtyResolver);
    config.addActiveDescriptor(newGuiceInjectionResolverDescriptor(
        locator, threeThirtyResolver));
    
    config.bind(BuilderHelper.link(DynamicConfigurationServiceImpl.class, false).
            to(DynamicConfigurationService.class).
            in(Singleton.class.getName()).
            localOnly().
            build());
    
    config.bind(BuilderHelper.createConstantDescriptor(
            new DefaultClassAnalyzer(locator)));
    
    config.bind(BuilderHelper.createDescriptorFromClass(ServiceLocatorRuntimeImpl.class));
    
    config.bind(BuilderHelper.createConstantDescriptor(
        new InstantiationServiceImpl()));
    
    config.commit();
    return locator;
  }
public static ServiceLocator newServiceLocator(String name, ServiceLocator parent) {
    if (parent != null && !(parent instanceof ServiceLocatorImpl)) {
      throw new IllegalArgumentException("name=" + name + ", parent=" + parent);
    }
    
    if (name == null) {
      name = PREFIX;
    }
    
    if (name.endsWith("-")) {
      name += NTH.incrementAndGet();
    }
    
    GuiceServiceLocator locator = new GuiceServiceLocator(name, parent);
    
    DynamicConfigurationImpl config = new DynamicConfigurationImpl(locator);
    
    config.bind(Utilities.getLocatorDescriptor(locator));
    
    ActiveDescriptor<InjectionResolver<javax.inject.Inject>> threeThirtyResolver 
      = newThreeThirtyInjectionResolverDescriptor(locator);
    
    config.addActiveDescriptor(threeThirtyResolver);
    config.addActiveDescriptor(newGuiceInjectionResolverDescriptor(
        locator, threeThirtyResolver));
    
    config.bind(BuilderHelper.link(DynamicConfigurationServiceImpl.class, false).
            to(DynamicConfigurationService.class).
            in(Singleton.class.getName()).
            localOnly().
            build());
    
    config.bind(BuilderHelper.createConstantDescriptor(
            new DefaultClassAnalyzer(locator)));
    
    config.bind(BuilderHelper.createDescriptorFromClass(ServiceLocatorRuntimeImpl.class));
    
    config.bind(BuilderHelper.createConstantDescriptor(
        new InstantiationServiceImpl()));
    
    config.commit();
    return locator;
  }
Creates and returns a {@link ServiceLocator}.

NOTE: This code should be very similar to HK2's own {@link ServiceLocatorGeneratorImpl}.