Open GoogleCodeExporter opened 9 years ago
You're running into a subtle but intended behavior here: Gin tries to create
your
type by calling GWT.create() instead of failing for @Optional.
I assume that A is an interface in your case. Unfortunately, Gin (currently)
cannot
tell whether there is a GWT binding for A and so falls back to trying that GWT
binding before taking @Optional into account.
Original comment by aragos
on 8 Dec 2009 at 2:21
If it is intended that optional method injection should not be supported, then
what is the recommended method for getting optional injections?
Original comment by smbec...@gmail.com
on 25 Aug 2010 at 7:41
Optional injection on methods is supported. It will break in the case where you
inject a type with default constructor (interface or class) and Gin attempts to
call GWT.create on your type.
Original comment by aragos
on 25 Aug 2010 at 7:55
Then I don't understand why this was closed out. Shouldn't that be a supported
scenario? All of the types that I am injecting are interfaces as I suspect is
the case for many other people that are using a dependency injection pattern.
Original comment by smbec...@gmail.com
on 26 Aug 2010 at 4:14
Indeed, why was this closed? Seems like a valid use case. Optional injection
simply doesn't work for interfaces or classes with default constructors.
Perhaps we need a new annotation to suppress GIN's "magic" deferred binding
call?
Original comment by mcart...@gmail.com
on 14 Aug 2012 at 3:05
I'm reopening the issue so we can look further into it. I am not sure how
complicated it would be to enable the suppression of Gin's magic but I bet
there's a way to do it.
Original comment by aragos
on 21 Aug 2012 at 2:38
Original issue reported on code.google.com by
bochensk...@gmail.com
on 7 Dec 2009 at 1:42