Hi,
The change in Guice 2 that was made in order to prevent Guice 2 from
instantiating objects with private constructors is causing us some
issues (i.e. the change described at
http://code.google.com/p/google-guice/issues/detail?id=72
).
Essentially, it is preventing us from using Guice 2 as a "drop in"
replacement for Guice 1 in our product. Suspect this may also be the
case with some other codebases out there too.
In order to ensure maximum backwards compatibility with code developed
using Guice 1, would it be possible to have a means of switching off
this check ? i.e. So that the new behaviour would be the default in
Guice 2, but could be disabled for maximum compatibility with code
bases developed against Guice 1.
Some more background to this request:
I came across the new check when testing the codebase for the product
I'm working on against guice-snapshot20081123. There are several
public classes with private constructors in the codebase that are
instantiated using Guice. So, this new check means that Guice 2 is not
a "drop-in" replacement for Guice 1 in the codebase - i.e. to use
Guice 2, the codebase would have to be changed so that the
constructors are annotated with @Inject.
While this change to the product codebase could be made, there is
another issue for us. Guice is also used as part of an extension
mechanism for the product, so that customers can extend and customize
it to meet their own requirements. So, some customers also have public
classes with private constructors that are instantiated via Guice 1.
We would like to move the product on to Guice 2 in a forthcoming
release in order to take advantage of some of the great new Guice 2
features. However, it will greatly complicate the product upgrade
process if we have to ask our customers to make changes to their
codebase (i.e. add the @Inject annotation to private constructors) in
order to take the upgrade.
Note that I've also added a note on this to the issue itself (i.e. at
http://code.google.com/p/google-guice/issues/detail?id=72).
Thanks,
Eoin.