Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 199 by david.nouls: GIN does not respect injection order when
subclassing
https://code.google.com/p/google-gin/issues/detail?id=199
What steps will reproduce the problem?
According to the Guice injection points document at:
https://github.com/google/guice/wiki/InjectionPoints
injection methods of super classes are called before the methods of a
subclass.
Here is some small unit test for Guice that shows that the correct order is
first ThingA.inject() and then ThingB.anotherInject().
If you use GIN, ThingB.anotherInject() is invoked before ThingA.inject()
public class InjectInheritance {
static class ThingA {
boolean initialized;
@Inject
public void inject() {
this.initialized = true;
System.out.println("ThingA:inject called");
}
}
static class ThingB extends ThingA {
private boolean testOK = false;
@Inject
public void anotherInject() {
testOK = this.initialized;
System.out.println("ThingB:anotherInject called");
}
public boolean isSuccess() {
return testOK;
}
}
@Test
public void guiceMethodInjectionInheritance() {
Module module = new AbstractModule() {
@Override
protected void configure() {
}
};
Injector guice = Guice.createInjector(module);
ThingB b = guice.getInstance(ThingB.class);
assertTrue(b.isSuccess());
}
// This part of the code needs to be executed by GIN.
public void ginInheritance() {
App app = GWT.create( App.class);
ThingB b = app.createB();
assertTrue(b.isSuccess());
}
@GinModules(MyGinModule.class)
static interface App extends Ginjector {
public ThingB createB();
}
static class MyGinModule extends AbstractGinModule {
@Override
protected void configure() {
}
}
What is the expected output? What do you see instead?
I expect this order of invocation
ThingA.inject();
ThingB.anotherInject();
However I get this in Gin:
ThingB.anotherInject();
ThingA.inject();
What version of the product are you using? On what operating system?
GWT 2.6.1 / GIN 2.1.2
Please provide any additional information below.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings