google / google/guice

Child Injector JIT Singletons Not Eager

Open
#386 3 comments 0 reactions 0 assignees View on GitHub
imported
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

_From [sberlin](https://code.google.com/u/sberlin/) on June 11, 2009 18:51:29_

Similar to issue 373 , but this time with implicit singletons.

Consider:

`@`Singleton class A { `@`Inject A(B b) {} }
`@`Singleton class B { }

AbstractModule {
 configure() {
    bind(A.class);
 }
}

If the module is used in a parent injector, B is eagerly constructed.  If
it's used in a child injector, B is not eagerly constructed.

FWIW, the patch I have attached to issue 38 can be used to fix this problem
(introducing a concept of listening to bindings, which can be used to
immediately instantiating singletons if they're supposed to be eager).

_Original issue: http://code.google.com/p/google-guice/issues/detail?id=386_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.