What should the following program print?
@Singleton
class B {
static int instanceCount = 0;
int instanceId = instanceCount++;
public static void main(String[] args) {
Injector injector = Guice.createInjector(Stage.PRODUCTION);
injector.getProvider(B.class);
System.out.println(instanceCount);
}
}
The problem is interesting in how it relates to issue 373. We have a
bug where we're not eagerly creating singletons at child-injector-
creation when their bindings live in the parent injector.
http://code.google.com/p/google-guice/issues/detail?id=373