michaelwiles / google-gin

Automatically exported from code.google.com/p/google-gin
Apache License 2.0
0 stars 0 forks source link

Guice allows installing modules twice if they are equal, GIN doesn't #130

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a GinModule class implementing equals() and hashCode() and adding 
bindings from its configure()
2. Reference the module twice from @GinModules, or install() it twice, or a mix 
of both, but always so that the installed module are equal (according to 
equals())

Or you can just install() the same module instance twice:
MyModule module = new MyModule();
binder.install(module);
binder.install(module);

What is the expected output? What do you see instead?
GWT.create() on the Ginjector will fail because of double-bounds keys (because 
the modules' configure() would have been called twice, once per instance).
If you do the same in Guice, the second module is discarded. This feature is 
used by Multibinder: each call to Multibinder.newSetBinder creates and installs 
a module, but those modules compare equal if the Key<?>s they're bound to (the 
one for the java.util.Set) are equal.

What version of the product are you using? On what operating system?
trunk r154

Please provide any additional information below.
GinModuleAdapter should implement equals() and hashCode() and delegate to the 
adapted GinModule, so that the Guice behavior is used (and in the eventuality 
it changes one day, GIN would still defer to Guice so there would be no 
"compatibility" issue).

Original issue reported on code.google.com by t.broyer on 26 Nov 2010 at 5:49

GoogleCodeExporter commented 9 years ago
http://codereview.appspot.com/3282042/

Original comment by t.broyer on 26 Nov 2010 at 5:52

GoogleCodeExporter commented 9 years ago

Original comment by aragos on 27 Nov 2010 at 7:37

GoogleCodeExporter commented 9 years ago
Fixed in r164.

Original comment by aragos on 4 Feb 2011 at 5:13