Comment #3 on issue 722 by sberlin: PrivateModule prevents interceptors to
Somewhat unfortunately, this is working-as-designed.
Because of the way just-in-time-bindings work, in the HelloModulePrivate,
Guice does not know that the statement:
also means that 'HelloWorldImpl' is 'private'. The statement is only
saying, "Link HelloWorld to HelloWordImpl". Because of that, HelloWordImpl
is actually being bound in the parent module, and the interceptor in the
private module can't see it.
This is why HelloModulePrivateNoInterface works -- you have a separate
bind(HelloWorldImpl.class) line, telling Guice that HelloWorldImpl wants to
If you add that bind statement (doesn't need to be a singleton as it is in
HelloModulePrivateNoInterface) in the HelloModulePrivate, then things will
Another fix would be to add 'binder().requireExplicitBindings()' to the
parent Module, and that will tell Guice that you don't want just-in-time
bindings at all, and everything should exist in the Module is was declared