code: public static Module fromClass(final Class<?> cls, final boolean override) {
          List<Module> modules = new ArrayList<>();
          // Iterate through all annotations of the main class, create a binding for the annotation
          // and add the module to the list of modules to install
          for (final Annotation annot : cls.getDeclaredAnnotations()) {
              final Class<? extends Annotation> type = annot.annotationType();
              Bootstrap bootstrap = type.getAnnotation(Bootstrap.class);
              if (bootstrap != null) {
                  LOG.info("Adding Module {}", bootstrap.module());
                  try {
                      modules.add(bootstrap.module().getConstructor(type).newInstance(annot));
                  } catch (Exception e) {
                      throw new RuntimeException(e);
                  }
              }
          }
          
          try {
              if (override) {
                  return Modules.override(combineAndOverride(modules)).with((Module)cls.newInstance());
              }
              else {
                  return Modules.combine(Modules.combine(modules), (Module)cls.newInstance());
              }
          }
          catch (Exception e) {
              throw new RuntimeException(e);
          }
      }
docs: Create a single module that derived from all bootstrap annotations
  on a class, where that class itself is a module.
  
  For example,
  <pre>
  {@code
  public class MainApplicationModule extends AbstractModule {
  @Override
  public void configure() {
  // Application specific bindings here
  }
  
  public static void main(String[] args) {
  Guice.createInjector(ModulesEx.fromClass(MainApplicationModule.class));
  }
  }
  }
  </pre>
  @author elandau