Since Elements.getElements() creates a flat list of bindings, constructions 
that rely on module de-duplication in install() don't work perfectly with 
module re-writing.  For example:

interface Interface {
}

static class Implementation implements Interface {
}

class Module1 extends AbstractModule {
  @Override
  public void configure() {
    bind(Interface.class).toInstance(new Implementation());
  }

  @Override
  public boolean equals(Object obj) {
    return obj instanceof Module1;
  }

  @Override
  public int hashCode() {
    return 0;
  }
}

class Module2 extends AbstractModule {
  @Override
  public void configure() {
    install(new Module1());
    install(new Module1()); // Fine
    install(Elements.getModule(Elements.getElements(new Module1()))); // A 
binding to Interface was already configured...
  }
}

This is especially noticeable with things like Multibinder/MapBinder which 
rely on module de-duplication.

My idea to fix this is to add an Element implementation "InstalledModule" 
or something that would hold the bindings from installed modules, and 
replay them only if the module wasn't already installed in the target 
binder.

That's obviously a pretty big change though.  Is there a better way I could 
approach this?  Is a "fix" even desired?

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to