Closed GoogleCodeExporter closed 8 years ago
I made the error in my example of using field injected resources in the
constructor - which are of course not yet injected:
@Inject
public ButtonLabelCallback buttonLabelCallback;
@Inject
public ButtonTitleCallback buttonTitleCallback;
public Foo(Button button, ButtonService buttonService) {
this.button = button;
this.buttonLabelService = buttonLabelService;
buttonService.getLabel(buttonLabelCallback); <-- Always null
buttonService.getTitle(buttonTitleCallback); <-- Always null
initWidget(button);
}
So excluding that situation, instead try to imagine using the ButtonService
after all injections occurred with the two inner class callbacks.
Regards
Original comment by np...@cisco.com
on 10 Jul 2010 at 7:55
Gin does not support inner (as opposed to nested) classes. It probably never
will since Guice doesn't either:
http://code.google.com/docreader/#p=google-guice&s=google-guice&t=FrequentlyAske
dQuestions
I'm surprised you didn't get a Guice error complaining about this binding in
your test, might investigate that later. But the main request - allow use of
inner classes - is something we can't do.
Original comment by aragos
on 12 Jul 2010 at 5:05
No error at all in development mode, but only when the field is uninitialized.
If I did:
private final ButtonService buttonService = new ButtonLabelCallback();
@Inject
public ButtonLabelCallback buttonLabelCallback;
Then I get an error. If I do a GWT compile either way, then I get a the same
mysterious error as: http://code.google.com/p/google-gin/issues/detail?id=99#c3
I realize this is not a forum for Guice in general, but does anyone have any
insight into why they are not supporting inner classes for field or method
injection?
Original comment by np...@cisco.com
on 12 Jul 2010 at 5:33
The reason is most likely that the enclosing might not be instantiable: if
there is no default constructor or the constructor is inaccessible, the
enclosing class cannot be created, therefore the inner class cannot use a newly
created instance of the enclosing class.
Original comment by aragos
on 19 Jul 2010 at 5:14
Original issue reported on code.google.com by
np...@cisco.com
on 10 Jul 2010 at 7:05