I want to bind a class to an instance but Guice won't let me, giving me the Binding points to itself error. I also want the instance to be a singleton.
So to give a bit more background. I have a class that I want to bind, but I can't since the bindClass and the instanceClass has to be different.
//This fails when bindClass==instanceClass
bind((bindClass)).to(instanceClass).in(Singleton.class);
There is a question with the title "Guice Beginner - How to bind concrete classes" that can be found here:
Guice Beginner - How to bind concrete classes?
The accepted answer is to not bind and the let the "Just In Time" binding do the job.
But what if you want a singleton of the instance, how do you do that?