How eager is eager?

0 views
Skip to first unread message

limpb...@gmail.com

unread,
Jun 4, 2009, 3:31:17 PM6/4/09
to google-guice-dev
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

Dhanji R. Prasanna

unread,
Jun 4, 2009, 4:20:40 PM6/4/09
to google-g...@googlegroups.com
1
Reply all
Reply to author
Forward
0 new messages