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
Injector does not respect constructor's private visibility #72
Comments
From antti.brax on March 16, 2007 05:45:08 I changed the tool constructor to throw a RuntimeException and here is the stack: |
From crazyboblee on March 16, 2007 08:49:58 I see where you're coming from but taking this out would break backward compatibility. :( Status: WontFix |
From kevinb9n on March 16, 2007 09:07:39 Is this kind of fix a possibility for 2.0 or later? |
From crazyboblee on March 16, 2007 10:32:09 Well, if we are going to do it, we should do it earlier like Ben said, i.e. 1.1. I'd Actually, I would prefer to always require |
From kevinb9n on October 06, 2008 12:21:44 Some users are concerned about this. Reopening because it's unclear why it was Status: Accepted |
From crazyboblee on October 06, 2008 12:31:18 I definitely think we should bite the bullet and fix this. I actually thought Jesse |
From limpbizkit on October 06, 2008 13:53:00 We no longer inject private constructors, such as the one for Collections.java. For example, consider That class has a package-private constructor. |
From limpbizkit on November 02, 2008 01:33:27 (No comment was entered for this change.) Labels: Milestone-Release2.0 |
From limpbizkit on December 28, 2008 21:34:10 The current code is a good balance between following the user's intents and ease-of-migration. Here's what
If we wanted to tighten the rules further, I think we'd make user code worse. For example, consider an inner public class Stopwatch { public Stopwatch() { // for testing If we were to forbid say, default package-private constructors, then the user would need to create a static class Ticker { long now() { That's lame, especially since it will impact lots of existing code. (Just changing our own tests is a large job) Status: Fixed |
From nimbus4321 on January 15, 2009 13:09:58 In order to ensure backwards compatibility with code developed using Guice 1, would Background to this request: While this change to the product codebase could be made, there is another issue for |
From limpbizkit on January 21, 2009 12:56:11
|
From nimbus4321 on January 23, 2009 02:22:46 For testing purposes, have already patched Guice 2 to disable the check. However, Also, suspect there may be some (few) others in this situation who are unaware of it
|
From nimbus4321 on January 29, 2009 05:03:29 See also this thread in the user group on this issue : http://groups.google.com/group/google-guice/browse_thread/thread/defa5ed074ac5aff |
From antti.brax on March 16, 2007 08:17:04
When an instance of the following Service class is created with an
Injector, an instance of the Tool class is created. It would be safer to
assume that this kind of a construction is a programming error.
public class Service {
@
Injectpublic Service(Tool tool) {
}
}
public class Tool {
private Tool() {
}
}
Original issue: http://code.google.com/p/google-guice/issues/detail?id=72
The text was updated successfully, but these errors were encountered: