Okay, I'll cook one up. On Tuesday, November 5, 2013 5:07:32 PM UTC-5, Sam Berlin wrote: > > Correct, though I wouldn't be opposed to a patch that deduplicated if the > listeners were equal. > > sam > > > On Tue, Nov 5, 2013 at 4:57 PM, Tavian Barnes <[email protected]<javascript:> > > wrote: > >> Thanks Sam. There seems to be no de-duplication for type/provision >> listener bindings though, correct? >> >> >> On Monday, November 4, 2013 1:24:41 PM UTC-5, Sam Berlin wrote: >> >>> We've fixed the mapbinder/multibinder issued in HEAD (haven't made it >>> into the beta release yet). But in general, you shouldn't rely on module >>> deduplication. Guice also does binding reduplication if the bindings are >>> exactly the same too. Binding deduping is generally better, and safe >>> through Modules.override. >>> >>> sam >>> On Nov 4, 2013 12:51 PM, "Tavian Barnes" <[email protected]> wrote: >>> >>>> 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 google-guice...@**googlegroups.com. >>>> To post to this group, send email to [email protected]. >>>> >>>> Visit this group at >>>> http://groups.google.com/**group/google-guice<http://groups.google.com/group/google-guice> >>>> . >>>> For more options, visit >>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>>> . >>>> >>> -- >> 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] <javascript:>. >> To post to this group, send email to [email protected]<javascript:> >> . >> Visit this group at http://groups.google.com/group/google-guice. >> For more options, visit https://groups.google.com/groups/opt_out. >> > >
-- 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.
