Sam, this is very nice work.
Lack of support for lazy singletons in Stage.PRODUCTION is a Guice
weakness. I'm curious if this is a general problem, or one that only
comes up when singletons are used aggressively for initialization,
like in your app. We don't have them in our apps at Google and so far
there hasn't been much complaining. But we're writing server-side
apps, where eager initialization and slow start-up aren't major
concerns.
I particularly like how you're using aggressive scope checks in
LazyBinder.registerAndCheckTypes(). The compareAndSet() call is also
handy to ensure you only get a single instance. Nice work.
I'm semi-reluctant to include all of this is in core Guice, because I
find that dynamic proxies can cause confusion in debugging I have the
same problem with EasyMock. I'm also anxious about the tradeoffs
between lazy instantiation (great!) and proxying everything (not so
great!).
For now, I've posted a link here from our Scopes wiki:
http://groups.google.com/group/google-guice/browse_thread/thread/e34e475609c2cec4
Cheers,
Jesse
PS - I admit that I'm a horrible hypocrite for giving dynamic proxies
much love in AssistedInject.