Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ImplementedBy creates & needs JIT bindings immediately #614

Closed
gissuebot opened this issue Jul 7, 2014 · 1 comment
Closed

@ImplementedBy creates & needs JIT bindings immediately #614

gissuebot opened this issue Jul 7, 2014 · 1 comment
Labels

Comments

@gissuebot
Copy link

From sberlin on March 10, 2011 18:29:13

Problem One

  1) Module binds Foo.
  2) Foo is @ImplementedBy(FooImpl.class)
  3) FooImpl class has a dependency on Bar
  4) Bar is @ImplementedBy(AutoBar.class)
  5) Module binds Bar to ExplicitBar.class
When figuring out the @ImplementedBy for FooImpl, it's creating a JIT binding for AutoBar too, and the getExistingBinding check when doing ExplicitBar sees AutoBar and fails.

InjectorImpl.createUninitializedBinding is called by BindingProcessor.visit(UntargettedBinding).  It ends up checking for @ImplementedBy (and @ProvidedBy) and creates JIT bindings for them.  The JIT bindings then lead to problem two...

Problem Two

If an untargetted binding is @ImplementedBy, its dependencies need to be eagerly creatable.  That is, if
 1) Foo is @ImplementedBy(FooImpl.class)
 2) FooImpl has a dependency on Bar
 3) Bar is explicitly bound in a module AFTER bind(Foo.class) is written
then FAIL, because Bar can't be created when constructing the JIT binding for FooImpl.

Original issue: http://code.google.com/p/google-guice/issues/detail?id=614

@gissuebot
Copy link
Author

From sberlin on March 10, 2011 16:04:12

fixed in r1526 & test cases added.  probably could be cleaned up a bit.. but i think any decent solution is going to require this second pass over the elements.

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant