What you have is a design problem. If A needs B to exist, and B needs A to exist, then either
- There is some other implicit object that provides data to both A and B, or
- You really have one logical class, and your implementation is trying to pretend it's two
The most straightforward way to resolve this is don't use Guice to construct these. I.e. A constructs a B and passes "this" to it and stores it as a field. Done.
Or if you want to use Guice to construct it (and arguably a better design), have
@Inject
A (AandBData data) {...}
...
@Inject
B (AandBData data) {...}
-Tim