vipx / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Misplaced annotation check may be overly strict when dealing with legacy code #718

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is not really a defect as such, and only affects a few scenarios, but just 
wanted to capture the use-case.

When dealing with legacy code you may encounter interfaces with misplaced 
annotations (such as @Singleton). They might use this as a kind of 
extension-point documentation, or as a way to generate bindings at runtime.

Currently any use of such an interface in Guice will cause the injector to 
throw a configuration error - the only way to avoid this is to use a different 
interface or get the interface changed upstream. However sometimes an upstream 
change is not possible, and it would be useful if instead the injector could be 
configured to log such errors as warnings.

While this particular use-case is narrow, there may be other errors which are 
technically not fatal and could be logged as warnings when running in some sort 
of "non-strict"/"legacy" mode or stage.

Original issue reported on code.google.com by mccu...@gmail.com on 30 Jul 2012 at 12:54

GoogleCodeExporter commented 9 years ago
Just for reference, attached is our current hack to turn off strict misplaced 
annotation checks for specific isolated legacy applications. A better approach 
would be to expose a non-strict setting via some kind of binder option or 
perhaps a new stage. Although ideally such applications would eventually be 
fixed and no such change would be required.

Original comment by mccu...@gmail.com on 30 Jul 2012 at 1:00

Attachments: